From bb9ce7a65a14d5b7b3199212d3254c0c35ba4e34 Mon Sep 17 00:00:00 2001 From: skalidindi53 Date: Thu, 29 Aug 2024 18:45:42 -0500 Subject: [PATCH] feat: Initial implementation of reactions notifications in federated convos Signed-off-by: skalidindi53 --- .../TalkV1/Notifier/MessageSentListener.php | 39 ++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php index 7f54abb095df..210d021bfd6e 100644 --- a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php +++ b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php @@ -99,6 +99,43 @@ public function handle(Event $event): void { $attendee = $participant->getAttendee(); $cloudId = $this->cloudIdManager->resolveCloudId($attendee->getActorId()); + //Reaction Handling logic + if ($chatMessage->getMessageType() === ChatManager::VERB_REACTION){ + $notificationLevel = $attendee->getNotificationLevel(); + + // Only notify if the notification level is set to always + if ($notificationLevel === Participant::NOTIFY_ALWAYS) { + // Create a federated notification for the reaction + $reactionMessageData = [ + 'subject' => 'reaction', + 'subjectData' => [ + 'userType' => $chatMessage->getActorType(), + 'userId' => $chatMessage->getActorId(), + ], + 'message' => $chatMessage->getMessage(), + 'commentId' => $event->getComment()->getId(), + 'dateTime' => $event->getComment()->getCreationDateTime()->format(\DateTime::ATOM), + ]; + + // Send notification for reaction + $reactionSuccess = $this->backendNotifier->sendMessageUpdate( + $cloudId->getRemote(), + $attendee->getId(), + $attendee->getAccessToken(), + $event->getRoom()->getToken(), + $reactionMessageData, + $unreadInfo, + ); + + if ($reactionSuccess === null) { + $this->participantService->removeAttendee($event->getRoom(), $participant, AAttendeeRemovedEvent::REASON_LEFT); + } + + // Continue to the next participant since this one has been notified + continue; + } + } + $lastReadMessage = $attendee->getLastReadMessage(); $lastMention = $attendee->getLastMentionMessage(); $lastMentionDirect = $attendee->getLastMentionDirect(); @@ -124,4 +161,4 @@ public function handle(Event $event): void { } } } -} +} \ No newline at end of file