diff --git a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php index 7f54abb095d..b040601de99 100644 --- a/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php +++ b/lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php @@ -57,6 +57,14 @@ public function handle(Event $event): void { $chatMessage = $this->messageParser->createMessage($event->getRoom(), null, $event->getComment(), $l); $this->messageParser->parseMessage($chatMessage); + $messageType = $chatMessage->getMessageType(); + + // Handle reaction events + if ($messageType === ChatManager::VERB_REACTION) { + $this->createReactionNotification($event->getRoom(), $event->getComment(), $chatMessage->getVerb(), $chatMessage->getMessageParameters()); + return; + } + $systemMessage = $chatMessage->getMessageType() === ChatManager::VERB_SYSTEM ? $chatMessage->getMessageRaw() : ''; if ($systemMessage !== 'message_edited' && $systemMessage !== 'message_deleted' @@ -124,4 +132,26 @@ public function handle(Event $event): void { } } } + + // /** + // * Creates a notification for the given chat message comment and mentioned + // * user ID. + // */ + // private function createReactionNotification(Room $chat, IComment $comment, string $subject, array $subjectData = [], ?IComment $reaction = null): INotification { + // $subjectData['userType'] = $reaction ? $reaction->getActorType() : $comment->getActorType(); + // $subjectData['userId'] = $reaction ? $reaction->getActorId() : $comment->getActorId(); + + // $notification = $this->notificationManager->createNotification(); + // $notification + // ->setApp('spreed') + // ->setObject('chat', $chat->getToken()) + // ->setSubject($subject, $subjectData) + // ->setMessage($comment->getVerb(), [ + // 'commentId' => $comment->getId(), + // ]) + // ->setDateTime($reaction ? $reaction->getCreationDateTime() : $comment->getCreationDateTime()); + + // return $notification; + // } + } diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 5550308477d..e959cc3182d 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -509,3 +509,44 @@ Feature: federation/chat | actorType | actorId | actorDisplayName | reaction | | users | participant1 | participant1-displayname | 🚀 | | federated_users | participant2@{$REMOTE_URL} | participant2-displayname | 🚀 | + + # Scenario: Verifying Notifications for Local Participants + + # Given the following "spreed" app config is set + # | federation_enabled | yes | + # And user "participant1" creates room "room" (v4) + # | roomType | 2 | + # | roomName | room | + # And user "participant1" adds federated_user "participant3" to room "room" with 200 (v4) + # And user "participant1" adds user "participant2" to room "room" with 200 (v4) + # And user "participant3" has the following invitations (v1) + # | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + # | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + # And user "participant3" accepts invite to room "room" of server "LOCAL" with 200 (v1) + # | id | name | type | remoteServer | remoteToken | + # | LOCAL::room | room | 2 | LOCAL | room | + + # # Enable Notifications for Local User + # And user "participant2" sets notifications to all for room "room" (v4) + + # #fed user + # #And user "participant3" sets notifications to all for room "room" (v4) + # And user "participant3" sets notifications to all for room "LOCAL::room" (v4) + + # # Sending a Message + # When user "participant1" sends message "Message 1" to room "room" with 201 + + # And user "participant1" react with "🚀" on message "Message 1" to room "room" with 201 + # | actorType | actorId | actorDisplayName | reaction | + # | users | participant1 | participant1-displayname | 🚀 | + + # # Verification for Message Notification + # Then user "participant2" has the following notifications + # | app | object_type | object_id | subject | message | + # | spreed | chat | room/Message 1 | participant1-displayname sent a message in conversation room | Message 1 | + # | spreed | room | room | participant1-displayname invited you to a group conversation: room | | + + # Then user "participant3" has the following notifications + # | app | object_type | object_id | subject | message | + # | spreed | chat | LOCAL::room/Message 1 | participant1-displayname sent a message in conversation room | Message 1 | + # #| spreed | room | LOCAL::room | participant1-displayname invited you to a group conversation: room | | \ No newline at end of file