]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/OStatusPlugin.php
Merge branch 'swat0' into 0.9.x
[quix0rs-gnu-social.git] / plugins / OStatus / OStatusPlugin.php
index 70971c5b34dab4e29afe5f37320f3a880e4d5d36..f9a8782faa119284f8414d508e8a637185b92c31 100644 (file)
@@ -28,6 +28,15 @@ set_include_path(get_include_path() . PATH_SEPARATOR . dirname(__FILE__) . '/ext
 
 class FeedSubException extends Exception
 {
+    function __construct($msg=null)
+    {
+        $type = get_class($this);
+        if ($msg) {
+            parent::__construct("$type: $msg");
+        } else {
+            parent::__construct($type);
+        }
+    }
 }
 
 class OStatusPlugin extends Plugin
@@ -238,17 +247,6 @@ class OStatusPlugin extends Plugin
         return true;
     }
 
-    /**
-     * Check if we've got remote replies to send via Salmon.
-     *
-     * @fixme push webfinger lookup & sending to a background queue
-     * @fixme also detect short-form name for remote subscribees where not ambiguous
-     */
-
-    function onEndNoticeSave($notice)
-    {
-    }
-
     /**
      * Find any explicit remote mentions. Accepted forms:
      *   Webfinger: @user@example.com
@@ -479,6 +477,24 @@ class OStatusPlugin extends Plugin
         }
     }
 
+    /**
+     * Tell the FeedSub infrastructure whether we have any active OStatus
+     * usage for the feed; if not it'll be able to garbage-collect the
+     * feed subscription.
+     *
+     * @param FeedSub $feedsub
+     * @param integer $count in/out
+     * @return mixed hook return code
+     */
+    function onFeedSubSubscriberCount($feedsub, &$count)
+    {
+        $oprofile = Ostatus_profile::staticGet('feeduri', $feedsub->uri);
+        if ($oprofile) {
+            $count += $oprofile->subscriberCount();
+        }
+        return true;
+    }
+
     /**
      * When about to subscribe to a remote user, start a server-to-server
      * PuSH subscription if needed. If we can't establish that, abort.
@@ -968,4 +984,18 @@ class OStatusPlugin extends Plugin
         $feed = $oprofile->feeduri;
         return false;
     }
+
+    function onStartGetProfileFromURI($uri, &$profile) {
+
+        // XXX: do discovery here instead (OStatus_profile::ensureProfileURI($uri))
+
+        $oprofile = Ostatus_profile::staticGet('uri', $uri);
+
+        if (!empty($oprofile) && !$oprofile->isGroup()) {
+            $profile = $oprofile->localProfile();
+            return false;
+        }
+
+        return true;
+    }
 }