From 8e042b537e5d1fdefe7ffa4985f8c49fab4f0bf5 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 26 Nov 2019 14:55:26 +0100 Subject: [PATCH] catch Talk exceptions Signed-off-by: Arthur Schiwon --- lib/Flow/Operation.php | 40 ++++++++++++++++------------------------ 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/lib/Flow/Operation.php b/lib/Flow/Operation.php index 582b8f968..c20825ab3 100644 --- a/lib/Flow/Operation.php +++ b/lib/Flow/Operation.php @@ -113,39 +113,31 @@ class Operation implements IOperation { $this->validateOperationConfig($mode, $token); } - /** - * Is being called by the workflow engine when an event was triggered that - * is configured for this operation. An evaluation whether the event - * qualifies for this operation to run has still to be done by the - * implementor by calling the RuleMatchers getMatchingOperations method - * and evaluating the results. - * - * If the implementor is an IComplexOperation, this method will not be - * called automatically. It can be used or left as no-op by the implementor. - * - * @since 18.0.0 - */ public function onEvent(string $eventName, Event $event, IRuleMatcher $ruleMatcher): void { $flows = $ruleMatcher->getMatchingOperations(self::class, false); foreach ($flows as $flow) { try { list($mode, $token) = $this->parseOperationConfig($flow['operation']); $this->validateOperationConfig($mode, $token); + + $room = $this->getRoom($token); + $participant = $this->getParticipant($room); + $this->chatManager->sendMessage( + $room, + $participant, + 'bots', + $participant->getUser(), + $this->prepareMention($mode, $participant) . 'MESSAGE TODO', + new \DateTime(), + null + ); } catch(UnexpectedValueException $e) { continue; + } catch (ParticipantNotFoundException $e) { + continue; + } catch (RoomNotFoundException $e) { + continue; } - - $room = $this->getRoom($token); - $participant = $this->getParticipant($room); - $this->chatManager->sendMessage( - $room, - $participant, - 'bots', - $participant->getUser(), - $this->prepareMention($mode, $participant) . 'MESSAGE TODO', - new \DateTime(), - null - ); } }