diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-22 12:07:37 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-09-22 14:08:56 +0300 |
commit | 9a599f12ce266fbac430be412c4e1bdb1a4cb87e (patch) | |
tree | 336d5c578a53209e5d8be35520f397fe0aa31827 /lib/Notification | |
parent | 64c66e7ba18ded8129f462496de6add5e91284a3 (diff) |
Allow to preload a user when getting the room by token
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib/Notification')
-rw-r--r-- | lib/Notification/Notifier.php | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index 4f2a26bd9..2c5bd965b 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -124,10 +124,11 @@ class Notifier implements INotifier { /** * @param string $objectId + * @param string $userId * @return Room * @throws RoomNotFoundException */ - protected function getRoom(string $objectId): Room { + protected function getRoom(string $objectId, string $userId): Room { if (array_key_exists($objectId, $this->rooms)) { if ($this->rooms[$objectId] === null) { throw new RoomNotFoundException('Room does not exist'); @@ -137,10 +138,16 @@ class Notifier implements INotifier { } try { - $room = $this->manager->getRoomByToken($objectId); + $room = $this->manager->getRoomByToken($objectId, $userId); $this->rooms[$objectId] = $room; return $room; } catch (RoomNotFoundException $e) { + if (!is_numeric($objectId)) { + // Room does not exist + $this->rooms[$objectId] = null; + throw $e; + } + try { // Before 3.2.3 the id was passed in notifications $room = $this->manager->getRoomById((int) $objectId); @@ -206,7 +213,7 @@ class Notifier implements INotifier { } try { - $room = $this->getRoom($notification->getObjectId()); + $room = $this->getRoom($notification->getObjectId(), $userId); } catch (RoomNotFoundException $e) { // Room does not exist throw new AlreadyProcessedException(); |