summaryrefslogtreecommitdiff
path: root/plugins/OStatus/classes
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-23 20:44:27 +0000
committerBrion Vibber <brion@pobox.com>2010-02-23 20:44:27 +0000
commit90d34b26c66ceb5d37a9c2782356b46361a523cc (patch)
tree2882722b42779e468bcf8ab2d074d506a5ee2f52 /plugins/OStatus/classes
parentc79c70ea2c2dadafa72c65dc4593a66fecb070e3 (diff)
OStatus: do PuSH subscription setup from subscribe/join event hooks, so resubscribing directly from a profile/group list works correctly if there aren't active subscriptions at the moment.
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r--plugins/OStatus/classes/Ostatus_profile.php26
1 files changed, 25 insertions, 1 deletions
diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php
index e8cc13c6c..91b957fa2 100644
--- a/plugins/OStatus/classes/Ostatus_profile.php
+++ b/plugins/OStatus/classes/Ostatus_profile.php
@@ -347,6 +347,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);