From eb5d7845cbac06b92906ff5f89e633250ca1304f 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 | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php index 7f54abb095df..cd6e0ab49ff0 100644 --- a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php +++ b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php @@ -99,6 +99,38 @@ public function handle(Event $event): void { $attendee = $participant->getAttendee(); $cloudId = $this->cloudIdManager->resolveCloudId($attendee->getActorId()); + if ($chatMessage->getMessageType() === ChatManager::VERB_REACTION){ + $notificationLevel = $attendee->getNotificationLevel(); + + if ($notificationLevel === Participant::NOTIFY_ALWAYS) { + $reactionMessageData = [ + 'subject' => 'reaction', + 'subjectData' => [ + 'userType' => $chatMessage->getActorType(), + 'userId' => $chatMessage->getActorId(), + ], + 'message' => $chatMessage->getMessage(), + 'commentId' => $event->getComment()->getId(), + 'dateTime' => $event->getComment()->getCreationDateTime()->format(\DateTime::ATOM), + ]; + + $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; + } + } + $lastReadMessage = $attendee->getLastReadMessage(); $lastMention = $attendee->getLastMentionMessage(); $lastMentionDirect = $attendee->getLastMentionDirect();