From 97e192102c33a56247dcff160d79a15b8aa8ee1f Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Tue, 19 Mar 2024 14:09:52 +0100 Subject: [PATCH] fix(federation): Mark notifications for federated rooms read similarly Signed-off-by: Joas Schilling --- .../Proxy/TalkV1/Controller/ChatController.php | 12 ++++++++++++ lib/Notification/Listener.php | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php index 781a5b6605f..e926e59072a 100644 --- a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php +++ b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php @@ -26,9 +26,11 @@ namespace OCA\Talk\Federation\Proxy\TalkV1\Controller; +use OCA\Talk\Chat\Notifier; use OCA\Talk\Exceptions\CannotReachRemoteException; use OCA\Talk\Federation\Proxy\TalkV1\ProxyRequest; use OCA\Talk\Federation\Proxy\TalkV1\UserConverter; +use OCA\Talk\Model\Attendee; use OCA\Talk\Participant; use OCA\Talk\ResponseDefinitions; use OCA\Talk\Room; @@ -52,6 +54,7 @@ public function __construct( protected UserConverter $userConverter, protected ParticipantService $participantService, protected RoomFormatter $roomFormatter, + protected Notifier $notifier, ICacheFactory $cacheFactory, ) { $this->proxyCacheMessages = $cacheFactory->isAvailable() ? $cacheFactory->createDistributed('talk/pcm/') : null; @@ -139,6 +142,11 @@ public function receiveMessages( int $markNotificationsAsRead): DataResponse { $cacheKey = sha1(json_encode([$room->getRemoteServer(), $room->getRemoteToken()])); + + if ($lookIntoFuture && $markNotificationsAsRead && $participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) { + $this->notifier->markMentionNotificationsRead($room, $participant->getAttendee()->getActorId()); + } + if ($lookIntoFuture) { if ($this->proxyCacheMessages instanceof ICache) { for ($i = 0; $i <= $timeout; $i++) { @@ -232,6 +240,10 @@ public function getMessageContext(Room $room, Participant $participant, int $mes ], ); + if ($participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS) { + $this->notifier->markMentionNotificationsRead($room, $participant->getAttendee()->getActorId()); + } + if ($proxy->getStatusCode() === Http::STATUS_NOT_MODIFIED) { return new DataResponse([], Http::STATUS_NOT_MODIFIED); } diff --git a/lib/Notification/Listener.php b/lib/Notification/Listener.php index b078879e90f..f622dd865ca 100644 --- a/lib/Notification/Listener.php +++ b/lib/Notification/Listener.php @@ -160,7 +160,7 @@ protected function markInvitationRead(Room $room, IUser $user): void { * Reaction: "{user} reacted with {reaction} in {call}" * * We should not mark reactions read based on the read-status of the comment - * they apply to, but the point in time when the reaction as done. + * they apply to, but the point in time when the reaction was done. * However, these messages are not visible and don't update the read marker, * so we purge them on joining the conversation. * This already happened before on the initial loading of a chat with