OStatus: hooked up follow/unfollow events on Salmon endpoint to create/destroy remote subscriber relationships

This commit is contained in:
Brion Vibber
2010-02-19 12:08:07 -08:00
parent 114eb310ca
commit a1a3ab1c58
4 changed files with 81 additions and 24 deletions

View File

@@ -253,17 +253,22 @@ class OStatusPlugin extends Plugin
*/
function onEndUnsubscribe($user, $other)
{
if ($user instanceof Profile) {
$profile = $user;
} else if ($user instanceof Profile) {
$profile = $user->getProfile();
}
$oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
if ($oprofile) {
// Notify the remote server of the unsub, if supported.
$oprofile->notify($user->getProfile(), ActivityVerb::UNFOLLOW, $oprofile);
$oprofile->notify($profile, ActivityVerb::UNFOLLOW, $oprofile);
// Drop the PuSH subscription if there are no other subscribers.
$sub = new Subscription();
$sub->subscribed = $other->id;
$sub->limit(1);
if (!$sub->find(true)) {
common_log(LOG_INFO, "Unsubscribing from now-unused feed $oprofile->feeduri on hub $oprofile->huburi");
common_log(LOG_INFO, "Unsubscribing from now-unused feed $oprofile->feeduri");
$oprofile->unsubscribe();
}
}