]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Disable PubSubHubBub hub pings automatically on private site (hub wouldn't be able...
authorBrion Vibber <brion@pobox.com>
Mon, 25 Jan 2010 17:07:24 +0000 (09:07 -0800)
committerBrion Vibber <brion@pobox.com>
Mon, 25 Jan 2010 17:07:24 +0000 (09:07 -0800)
[Might be good to think of a core way to mark a plugin as disabled when it initializes.]

plugins/PubSubHubBub/PubSubHubBubPlugin.php

index ce6086df9443933b6c51e8075f243809afbaedb3..a880dc8666f5bc2b2f912917bcd9d66d90f72b2e 100644 (file)
@@ -79,6 +79,21 @@ class PubSubHubBubPlugin extends Plugin
         parent::__construct();
     }
 
+    /**
+     * Check if plugin should be active; may be mass-enabled.
+     * @return boolean
+     */
+
+    function enabled()
+    {
+        if (common_config('site', 'private')) {
+            // PuSH relies on public feeds
+            return false;
+        }
+        // @fixme check for being on a private network?
+        return true;
+    }
+
     /**
      * Hooks the StartApiAtom event
      *
@@ -92,8 +107,9 @@ class PubSubHubBubPlugin extends Plugin
 
     function onStartApiAtom($action)
     {
-        $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null);
-
+        if ($this->enabled()) {
+            $action->element('link', array('rel' => 'hub', 'href' => $this->hub), null);
+        }
         return true;
     }
 
@@ -110,9 +126,11 @@ class PubSubHubBubPlugin extends Plugin
 
     function onStartApiRss($action)
     {
-        $action->element('atom:link', array('rel' => 'hub',
-                                            'href' => $this->hub),
-                         null);
+        if ($this->enabled()) {
+            $action->element('atom:link', array('rel' => 'hub',
+                                                'href' => $this->hub),
+                             null);
+        }
         return true;
     }
 
@@ -130,6 +148,9 @@ class PubSubHubBubPlugin extends Plugin
 
     function onHandleQueuedNotice($notice)
     {
+        if (!$this->enabled()) {
+            return false;
+        }
         $publisher = new Publisher($this->hub);
 
         $feeds = array();
@@ -243,16 +264,21 @@ class PubSubHubBubPlugin extends Plugin
 
     function onPluginVersion(&$versions)
     {
+        $about = _m('The PubSubHubBub plugin pushes RSS/Atom updates '.
+                    'to a <a href = "'.
+                    'http://pubsubhubbub.googlecode.com/'.
+                    '">PubSubHubBub</a> hub.');
+        if (!$this->enabled()) {
+            $about = '<span class="disabled" style="color:gray">' . $about . '</span> ' .
+                     _m('(inactive on private site)');
+        }
         $versions[] = array('name' => 'PubSubHubBub',
                             'version' => STATUSNET_VERSION,
                             'author' => 'Craig Andrews',
                             'homepage' =>
                             'http://status.net/wiki/Plugin:PubSubHubBub',
                             'rawdescription' =>
-                            _m('The PubSubHubBub plugin pushes RSS/Atom updates '.
-                               'to a <a href = "'.
-                               'http://pubsubhubbub.googlecode.com/'.
-                               '">PubSubHubBub</a> hub.'));
+                            $about);
 
         return true;
     }