]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/Ostatus_profile.php
OStatus: do PuSH subscription setup from subscribe/join event hooks, so resubscribing...
[quix0rs-gnu-social.git] / plugins / OStatus / classes / Ostatus_profile.php
index e8cc13c6c1350a0a1b94944062df3f8cb3529b62..91b957fa23f591515863ee1d6bf284e6be325346 100644 (file)
@@ -346,6 +346,29 @@ class Ostatus_profile extends Memcached_DataObject
         }
     }
 
+    /**
+     * Check if this remote profile has any active local subscriptions, and
+     * if not drop the PuSH subscription feed.
+     *
+     * @return boolean
+     */
+    public function garbageCollect()
+    {
+        if ($this->isGroup()) {
+            $members = $this->localGroup()->getMembers(0, 1);
+            $count = $members->N;
+        } else {
+            $count = $this->localProfile()->subscriberCount();
+        }
+        if ($count == 0) {
+            common_log(LOG_INFO, "Unsubscribing from now-unused remote feed $oprofile->feeduri");
+            $this->unsubscribe();
+            return true;
+        } else {
+            return false;
+        }
+    }
+
     /**
      * Send an Activity Streams notification to the remote Salmon endpoint,
      * if so configured.
@@ -379,7 +402,8 @@ class Ostatus_profile extends Memcached_DataObject
                                 'xmlns:activity' => 'http://activitystrea.ms/spec/1.0/',
                                 'xmlns:thr' => 'http://purl.org/syndication/thread/1.0',
                                 'xmlns:georss' => 'http://www.georss.org/georss',
-                                'xmlns:ostatus' => 'http://ostatus.org/schema/1.0');
+                                'xmlns:ostatus' => 'http://ostatus.org/schema/1.0',
+                                'xmlns:poco' => 'http://portablecontacts.net/spec/1.0');
 
             $entry = new XMLStringer();
             $entry->elementStart('entry', $attributes);