summaryrefslogtreecommitdiff
path: root/plugins/OStatus/OStatusPlugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/OStatus/OStatusPlugin.php')
-rw-r--r--plugins/OStatus/OStatusPlugin.php42
1 files changed, 42 insertions, 0 deletions
diff --git a/plugins/OStatus/OStatusPlugin.php b/plugins/OStatus/OStatusPlugin.php
index c61e2cc5f..6fef20d6f 100644
--- a/plugins/OStatus/OStatusPlugin.php
+++ b/plugins/OStatus/OStatusPlugin.php
@@ -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
@@ -158,6 +167,9 @@ class OStatusPlugin extends Plugin
// Also, we'll add in the salmon link
$salmon = common_local_url($salmonAction, array('id' => $id));
+ $feed->addLink($salmon, array('rel' => Salmon::REL_SALMON));
+
+ // XXX: these are deprecated
$feed->addLink($salmon, array('rel' => Salmon::NS_REPLIES));
$feed->addLink($salmon, array('rel' => Salmon::NS_MENTIONS));
}
@@ -477,6 +489,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.
*
@@ -953,4 +983,16 @@ class OStatusPlugin extends Plugin
}
return false;
}
+
+ public function onStartProfileGetAtomFeed($profile, &$feed)
+ {
+ $oprofile = Ostatus_profile::staticGet('profile_id', $profile->id);
+
+ if (empty($oprofile)) {
+ return true;
+ }
+
+ $feed = $oprofile->feeduri;
+ return false;
+ }
}