summaryrefslogtreecommitdiff
path: root/plugins/OStatus/classes
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/classes
parent4ae760cb62657e68b6b2313e64d2bb59fe264df4 (diff)
OStatus: garbage collect unused PuSH subscriptions when the last local subscriber unsubs
Diffstat (limited to 'plugins/OStatus/classes')
-rw-r--r--plugins/OStatus/classes/Feedinfo.php22
1 files changed, 16 insertions, 6 deletions
diff --git a/plugins/OStatus/classes/Feedinfo.php b/plugins/OStatus/classes/Feedinfo.php
index 2344a4a0e..d3cccd42f 100644
--- a/plugins/OStatus/classes/Feedinfo.php
+++ b/plugins/OStatus/classes/Feedinfo.php
@@ -112,9 +112,9 @@ class Feedinfo extends Memcached_DataObject
/*extra*/ null,
/*auto_increment*/ true),
new ColumnDef('profile_id', 'integer',
- null, true),
+ null, true, 'UNI'),
new ColumnDef('group_id', 'integer',
- null, true),
+ null, true, 'UNI'),
new ColumnDef('feeduri', 'varchar',
255, false, 'UNI'),
new ColumnDef('homeuri', 'varchar',
@@ -160,7 +160,7 @@ class Feedinfo extends Memcached_DataObject
function keyTypes()
{
- return array('id' => 'K', 'feeduri' => 'U'); // @fixme we'll need a profile_id key at least
+ return array('id' => 'K', 'profile_id' => 'U', 'group_id' => 'U', 'feeduri' => 'U');
}
function sequenceKey()
@@ -261,11 +261,11 @@ class Feedinfo extends Memcached_DataObject
/**
* Send a subscription request to the hub for this feed.
- * The hub will later send us a confirmation POST to /feedsub/callback.
+ * The hub will later send us a confirmation POST to /main/push/callback.
*
* @return bool true on success, false on failure
*/
- public function subscribe()
+ public function subscribe($mode='subscribe')
{
if (common_config('feedsub', 'nohub')) {
// Fake it! We're just testing remote feeds w/o hubs.
@@ -278,7 +278,7 @@ class Feedinfo extends Memcached_DataObject
try {
$callback = common_local_url('pushcallback', array('feed' => $this->id));
$headers = array('Content-Type: application/x-www-form-urlencoded');
- $post = array('hub.mode' => 'subscribe',
+ $post = array('hub.mode' => $mode,
'hub.callback' => $callback,
'hub.verify' => 'async',
'hub.verify_token' => $this->verify_token,
@@ -309,6 +309,16 @@ class Feedinfo extends Memcached_DataObject
}
/**
+ * Send an unsubscription request to the hub for this feed.
+ * The hub will later send us a confirmation POST to /main/push/callback.
+ *
+ * @return bool true on success, false on failure
+ */
+ public function unsubscribe() {
+ return $this->subscribe('unsubscribe');
+ }
+
+ /**
* Read and post notices for updates from the feed.
* Currently assumes that all items in the feed are new,
* coming from a PuSH hub.