]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add hooks for OStatus notification on subscribe/unsubscribe
authorEvan Prodromou <evan@status.net>
Sat, 20 Feb 2010 16:48:42 +0000 (11:48 -0500)
committerEvan Prodromou <evan@status.net>
Sat, 20 Feb 2010 16:48:42 +0000 (11:48 -0500)
plugins/OStatus/OStatusPlugin.php

index e1f3fd9d3713617ad245025832f8bfecd9e6c766..9e6d03177fd56d9f7518e83c5eae94fbb999d783 100644 (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;
+    }
 }