]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/HubSub.php
In very specific circumstances we can bulkDistribute 0 notices
[quix0rs-gnu-social.git] / plugins / OStatus / classes / HubSub.php
index 30c32ac1aa2b18c1089063a99f0a0ae8a91fa9b8..7ffda88e748c596496177e7f26c684ba03e96e36 100644 (file)
@@ -31,8 +31,8 @@ class HubSub extends Managed_DataObject
     public $__table = 'hubsub';
 
     public $hashkey; // sha1(topic . '|' . $callback); (topic, callback) key is too long for myisam in utf8
-    public $topic;
-    public $callback;
+    public $topic;      // varchar(191)   not 255 because utf8mb4 takes more space
+    public $callback;   // varchar(191)   not 255 because utf8mb4 takes more space
     public $secret;
     public $lease;
     public $sub_start;
@@ -55,10 +55,10 @@ class HubSub extends Managed_DataObject
         return array(
             'fields' => array(
                 'hashkey' => array('type' => 'char', 'not null' => true, 'length' => 40, 'description' => 'HubSub hashkey'),
-                'topic' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub topic'),
-                'callback' => array('type' => 'varchar', 'not null' => true, 'length' => 255, 'description' => 'HubSub callback'),
+                'topic' => array('type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'HubSub topic'),
+                'callback' => array('type' => 'varchar', 'not null' => true, 'length' => 191, 'description' => 'HubSub callback'),
                 'secret' => array('type' => 'text', 'description' => 'HubSub stored secret'),
-                'lease' => array('type' => 'int', 'not null' => true, 'description' => 'HubSub leasetime'),
+                'lease' => array('type' => 'int', 'description' => 'HubSub leasetime'),
                 'sub_start' => array('type' => 'datetime', 'description' => 'subscription start'),
                 'sub_end' => array('type' => 'datetime', 'description' => 'subscription end'),
                 'created' => array('type' => 'datetime', 'not null' => true, 'description' => 'date this record was created'),
@@ -226,8 +226,12 @@ class HubSub extends Managed_DataObject
      * @param string $atom well-formed Atom feed
      * @param array $pushCallbacks list of callback URLs
      */
-    function bulkDistribute($atom, $pushCallbacks)
+    function bulkDistribute($atom, array $pushCallbacks)
     {
+        if (empty($pushCallbacks)) {
+            common_log(LOG_ERR, 'Callback list empty for bulkDistribute.');
+            return false;
+        }
         $data = array('atom' => $atom,
                       'topic' => $this->topic,
                       'pushCallbacks' => $pushCallbacks);
@@ -235,6 +239,7 @@ class HubSub extends Managed_DataObject
                              count($pushCallbacks) . " sites");
         $qm = QueueManager::get();
         $qm->enqueue($data, 'hubprep');
+        return true;
     }
 
     /**