]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - plugins/OStatus/lib/pushinqueuehandler.php
Merge branch 'profile' into 'nightly'
[quix0rs-gnu-social.git] / plugins / OStatus / lib / pushinqueuehandler.php
index 9802baffe238823d3a28d993f31fad34e3c8e6f5..4946186cf4199b6257ace3c105752d5b0d487716 100644 (file)
  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
  */
 
-if (!defined('STATUSNET')) {
-    exit(1);
-}
+if (!defined('GNUSOCIAL')) { exit(1); }
 
 /**
- * Process a feed distribution POST from a PuSH hub.
+ * Process a feed distribution POST from a WebSub (previously PuSH) hub.
  * @package FeedSub
  * @author Brion Vibber <brion@status.net>
  */
@@ -41,15 +39,17 @@ class PushInQueueHandler extends QueueHandler
         $post = $data['post'];
         $hmac = $data['hmac'];
 
-        $feedsub = FeedSub::getKV('id', $feedsub_id);
-        if ($feedsub) {
-            try {
-                $feedsub->receive($post, $hmac);
-            } catch(Exception $e) {
-                common_log(LOG_ERR, "Exception during PuSH input processing for $feedsub->uri: " . $e->getMessage());
+        try {
+            $feedsub = FeedSub::getByID($feedsub_id);
+            $feedsub->receive($post, $hmac);
+        } catch(NoResultException $e) {
+            common_log(LOG_INFO, "Discarding POST to unknown feed subscription id {$feedsub_id}");
+        } catch(Exception $e) {
+            if (is_null($feedsub)) {
+                common_log(LOG_ERR, "Exception "._ve(get_class($e))." during WebSub push input processing where FeedSub->receive returned null!" . _ve($e->getMessage()));
+            } else {
+                common_log(LOG_ERR, "Exception "._ve(get_class($e))." during WebSub push input processing for {$feedsub->getUri()}: " . _ve($e->getMessage()));
             }
-        } else {
-            common_log(LOG_ERR, "Discarding POST to unknown feed subscription id $feedsub_id");
         }
         return true;
     }