summaryrefslogtreecommitdiff
path: root/plugins/OStatus/OStatusPlugin.php
diff options
context:
space:
mode:
authorBrion Vibber <brion@pobox.com>2010-02-11 00:09:20 +0000
committerBrion Vibber <brion@pobox.com>2010-02-11 00:09:20 +0000
commit71151b2583d81e28c5f5d42a690c649f4e84f3bf (patch)
tree4b2461f04a0ee9ec4f4b25677186403657a58c3e /plugins/OStatus/OStatusPlugin.php
parent4ae760cb62657e68b6b2313e64d2bb59fe264df4 (diff)
OStatus: garbage collect unused PuSH subscriptions when the last local subscriber unsubs
Diffstat (limited to 'plugins/OStatus/OStatusPlugin.php')
-rw-r--r--plugins/OStatus/OStatusPlugin.php23
1 files changed, 20 insertions, 3 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index 4b9b4d2c3..ce02393e4 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -234,13 +234,30 @@ class OStatusPlugin extends Plugin
}
}
+
+ /**
+ * Garbage collect unused feeds on unsubscribe
+ */
+ function onEndUnsubscribe($user, $other)
+ {
+ $feed = Feedinfo::staticGet('profile_id', $other->id);
+ if ($feed) {
+ $sub = new Subscription();
+ $sub->subscribed = $other->id;
+ $sub->limit(1);
+ if (!$sub->find(true)) {
+ common_log(LOG_INFO, "Unsubscribing from now-unused feed $feed->feeduri on hub $feed->huburi");
+ $feed->unsubscribe();
+ }
+ }
+ return true;
+ }
+
function onCheckSchema() {
- // warning: the autoincrement doesn't seem to set.
- // alter table feedinfo change column id id int(11) not null auto_increment;
$schema = Schema::get();
$schema->ensureTable('feedinfo', Feedinfo::schemaDef());
$schema->ensureTable('hubsub', HubSub::schemaDef());
return true;
- }
+ }
}