diff options
author | Joas Schilling <coding@schilljs.com> | 2020-09-22 12:07:37 +0300 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2020-09-22 22:12:41 +0300 |
commit | 753d83c4781f8ae8cbd0c1c0be25dff2c4960627 (patch) | |
tree | 1722df32b03972415d10c0b594cf356cb238b343 /lib/Notification/Notifier.php | |
parent | 94203a56b818d2e529aebd3f552f8908daf501d5 (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/Notifier.php')
-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(); |