From fa8e02b832ea71d9b8ccadc9b81931f9834e6333 Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Wed, 20 Jan 2016 14:55:41 +0100 Subject: [PATCH] Handle exceptions when salmon slapping Make it so notifyDeferred actually _always_ throws exceptions and handle them in the places it is called. --- plugins/OStatus/classes/Ostatus_profile.php | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/plugins/OStatus/classes/Ostatus_profile.php b/plugins/OStatus/classes/Ostatus_profile.php index e3802ea94c..2a540e21d2 100644 --- a/plugins/OStatus/classes/Ostatus_profile.php +++ b/plugins/OStatus/classes/Ostatus_profile.php @@ -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; -- 2.39.5