]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/classes/FeedSub.php
Merge branch 'ostatus-crop' into 0.9.x
[quix0rs-gnu-social.git] / plugins / OStatus / classes / FeedSub.php
index bf9d063fa111ed6b7091d09e94b48606a6e818a5..80ba37bc111aefaaeaee9059a0472a4c2cb4cb7f 100644 (file)
@@ -110,7 +110,7 @@ class FeedSub extends Memcached_DataObject
                                    /*size*/ null,
                                    /*nullable*/ false,
                                    /*key*/ 'PRI',
-                                   /*default*/ '0',
+                                   /*default*/ null,
                                    /*extra*/ null,
                                    /*auto_increment*/ true),
                      new ColumnDef('uri', 'varchar',
@@ -291,10 +291,9 @@ class FeedSub extends Memcached_DataObject
             $headers = array('Content-Type: application/x-www-form-urlencoded');
             $post = array('hub.mode' => $mode,
                           'hub.callback' => $callback,
-                          'hub.verify' => 'async',
+                          'hub.verify' => 'sync',
                           'hub.verify_token' => $this->verify_token,
                           'hub.secret' => $this->secret,
-                          //'hub.lease_seconds' => 0,
                           'hub.topic' => $this->uri);
             $client = new HTTPClient();
             $response = $client->post($this->huburi, $headers, $post);
@@ -317,8 +316,8 @@ class FeedSub extends Memcached_DataObject
             common_log(LOG_ERR, __METHOD__ . ": error \"{$e->getMessage()}\" hitting hub $this->huburi subscribing to $this->uri");
 
             $orig = clone($this);
-            $this->verify_token = null;
-            $this->sub_state = null;
+            $this->verify_token = '';
+            $this->sub_state = 'inactive';
             $this->update($orig);
             unset($orig);
 
@@ -343,7 +342,7 @@ class FeedSub extends Memcached_DataObject
         } else {
             $this->sub_end = null;
         }
-        $this->lastupdate = common_sql_now();
+        $this->modified = common_sql_now();
 
         return $this->update($original);
     }
@@ -362,7 +361,7 @@ class FeedSub extends Memcached_DataObject
         $this->sub_state = '';
         $this->sub_start = '';
         $this->sub_end = '';
-        $this->lastupdate = common_sql_now();
+        $this->modified = common_sql_now();
 
         return $this->update($original);
     }
@@ -372,6 +371,12 @@ class FeedSub extends Memcached_DataObject
      * feed (as a DOMDocument) will be passed to the StartFeedSubHandleFeed
      * and EndFeedSubHandleFeed events for processing.
      *
+     * Not guaranteed to be running in an immediate POST context; may be run
+     * from a queue handler.
+     *
+     * Side effects: the feedsub record's lastupdate field will be updated
+     * to the current time (not published time) if we got a legit update.
+     *
      * @param string $post source of Atom or RSS feed
      * @param string $hmac X-Hub-Signature header, if present
      */
@@ -402,6 +407,10 @@ class FeedSub extends Memcached_DataObject
             return;
         }
 
+        $orig = clone($this);
+        $this->last_update = common_sql_now();
+        $this->update($orig);
+
         Event::handle('StartFeedSubReceive', array($this, $feed));
         Event::handle('EndFeedSubReceive', array($this, $feed));
     }
@@ -441,3 +450,4 @@ class FeedSub extends Memcached_DataObject
     }
 
 }
+