add hooks for OStatus notification on subscribe/unsubscribe

This commit is contained in:
Evan Prodromou 2010-02-20 11:48:42 -05:00
parent ab4ec095e8
commit 866b647062

View File

@ -335,4 +335,48 @@ class OStatusPlugin extends Plugin
common_log(LOG_DEBUG, "No ostatus profile for incoming feed $feedsub->uri");
}
}
function onEndSubscribe($subscriber, $other)
{
$user = User::staticGet('id', $subscriber->id);
if (empty($user)) {
return true;
}
$oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
if (empty($oprofile)) {
return true;
}
// We have a local user subscribing to a remote profile; make the
// magic happen!
$oprofile->notify($subscriber, ActivityVerb::FOLLOW);
return true;
}
function onEndUnsubscribe($subscriber, $other)
{
$user = User::staticGet('id', $subscriber->id);
if (empty($user)) {
return true;
}
$oprofile = Ostatus_profile::staticGet('profile_id', $other->id);
if (empty($oprofile)) {
return true;
}
// We have a local user subscribing to a remote profile; make the
// magic happen!
$oprofile->notify($subscriber, ActivityVerb::UNFOLLOW);
return true;
}
}