]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Handle exceptions when salmon slapping
authorMikael Nordfeldth <mmn@hethane.se>
Wed, 20 Jan 2016 13:55:41 +0000 (14:55 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Wed, 20 Jan 2016 14:32:39 +0000 (15:32 +0100)
Make it so notifyDeferred actually _always_ throws exceptions and handle
them in the places it is called.

plugins/OStatus/classes/Ostatus_profile.php

index d36cbe21d66c902579e680224cfa2d0a967da3d5..a8269bdf0728594687656769ec2ef4e12e719446 100644 (file)
@@ -376,14 +376,19 @@ class Ostatus_profile extends Managed_DataObject
     public function notifyDeferred($entry, $actor)
     {
         if ($this->salmonuri) {
-            common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}");
-            $data = array('salmonuri' => $this->salmonuri,
-                          'entry' => $this->notifyPrepXml($entry),
-                          'actor' => $actor->getID(),
-                          'target' => $this->localProfile()->getID());
-
-            $qm = QueueManager::get();
-            return $qm->enqueue($data, 'salmon');
+            try {
+                common_debug("OSTATUS: user {$actor->getNickname()} ({$actor->getID()}) wants to ping {$this->localProfile()->getNickname()} on {$this->salmonuri}");
+                $data = array('salmonuri' => $this->salmonuri,
+                              'entry' => $this->notifyPrepXml($entry),
+                              'actor' => $actor->getID(),
+                              'target' => $this->localProfile()->getID());
+
+                $qm = QueueManager::get();
+                return $qm->enqueue($data, 'salmon');
+            } catch (Exception $e) {
+                common_log(LOG_ERR, 'OSTATUS: Something went wrong when creating a Salmon slap: '._ve($e->getMessage()));
+                return false;
+            }
         }
 
         return false;