Skip to content

Commit

Permalink
feat: Initial implementation of reactions notifications in federated …
Browse files Browse the repository at this point in the history
…convos

Signed-off-by: skalidindi53 <[email protected]>
  • Loading branch information
skalidindi53 committed Aug 29, 2024
1 parent c9d84d8 commit bb9ce7a
Showing 1 changed file with 38 additions and 1 deletion.
39 changes: 38 additions & 1 deletion lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -124,4 +161,4 @@ public function handle(Event $event): void {
}
}
}
}
}

0 comments on commit bb9ce7a

Please sign in to comment.