Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat; Reactions notifications in fully subscribed federated convos #13183

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,14 @@
$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());

Check failure on line 64 in lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php:64:11: UndefinedMethod: Method OCA\Talk\Federation\Proxy\TalkV1\Notifier\MessageSentListener::createReactionNotification does not exist (see https://psalm.dev/022)

Check failure on line 64 in lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php

View workflow job for this annotation

GitHub Actions / static-psalm-analysis

UndefinedMethod

lib/Federation/Proxy/TalkV1/Notifier/MessageSentListener.php:64:93: UndefinedMethod: Method OCA\Talk\Model\Message::getVerb does not exist (see https://psalm.dev/022)
return;
}

$systemMessage = $chatMessage->getMessageType() === ChatManager::VERB_SYSTEM ? $chatMessage->getMessageRaw() : '';
if ($systemMessage !== 'message_edited'
&& $systemMessage !== 'message_deleted'
Expand Down Expand Up @@ -124,4 +132,26 @@
}
}
}

// /**
// * 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;
// }

}
41 changes: 41 additions & 0 deletions tests/integration/features/federation/chat.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Loading