summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Prodromou <evan@status.net>2010-02-20 11:48:42 -0500
committerEvan Prodromou <evan@status.net>2010-02-20 11:48:42 -0500
commit866b6470629b570b9f817553f85f6d8e801f0d43 (patch)
tree2df54736462ee2017c1d89fedcbfeeab737970dd
parentab4ec095e811f86c50fbc1cd71144b11d6b86d50 (diff)
add hooks for OStatus notification on subscribe/unsubscribe
-rw-r--r--plugins/OStatus/OStatusPlugin.php44
1 files changed, 44 insertions, 0 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index e1f3fd9d3..9e6d03177 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -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;
+ }
}