diff options
author | Joas Schilling <coding@schilljs.com> | 2023-05-24 12:24:38 +0200 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2023-05-24 16:22:41 +0200 |
commit | 63c020a1fb89199240be67077045450b8c2baed6 (patch) | |
tree | 2aceb23869f86a1fd9ee68780c1b478cba891c9d /lib | |
parent | cbc47f5eaa6c3725d454ccc9cb7bc37aab42be50 (diff) |
fix(chat): Update own read marker before triggering events when posting
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Chat/ChatManager.php | 14 | ||||
-rw-r--r-- | lib/Controller/ChatController.php | 2 |
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index 1de8610ec..34f348737 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -29,6 +29,7 @@ use OC\Memcache\ArrayCache; use OC\Memcache\NullCache; use OCA\Talk\Events\ChatEvent; use OCA\Talk\Events\ChatParticipantEvent; +use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Model\Attendee; use OCA\Talk\Model\Poll; use OCA\Talk\Participant; @@ -199,6 +200,17 @@ class ChatManager { $this->notifier->notifyOtherParticipant($chat, $comment, [], false); } + if (!$shouldSkipLastMessageUpdate && $sendNotifications) { + // Update the read-marker for the author when it is a "relevant" system message, + // e.g. sharing an item to the chat + try { + $participant = $this->participantService->getParticipantByActor($chat, $actorType, $actorId); + $this->participantService->updateLastReadMessage($participant, (int) $comment->getId()); + } catch (ParticipantNotFoundException) { + // Participant not found => No read-marker update needed + } + } + $this->dispatcher->dispatch(self::EVENT_AFTER_SYSTEM_MESSAGE_SEND, $event); } catch (NotFoundException $e) { } @@ -280,6 +292,8 @@ class ChatManager { try { $this->commentsManager->save($comment); + $this->participantService->updateLastReadMessage($participant, (int) $comment->getId()); + // Update last_message if ($comment->getActorType() !== 'bots' || $comment->getActorId() === 'changelog') { $this->roomService->setLastMessage($chat, $comment); diff --git a/lib/Controller/ChatController.php b/lib/Controller/ChatController.php index ea410faf8..f306d5ccd 100644 --- a/lib/Controller/ChatController.php +++ b/lib/Controller/ChatController.php @@ -179,8 +179,6 @@ class ChatController extends AEnvironmentAwareController { return $response; } - $this->participantService->updateLastReadMessage($this->participant, (int) $comment->getId()); - $data = $chatMessage->toArray($this->getResponseFormat()); if ($parentMessage instanceof Message) { $data['parent'] = $parentMessage->toArray($this->getResponseFormat()); |