diff options
author | Joas Schilling <coding@schilljs.com> | 2024-03-15 11:06:24 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-03-15 11:06:24 +0100 |
commit | df2d18095fbc5a18f6586b404f93823475f71050 (patch) | |
tree | 6d0ce72e70bf35a68db74da1a4050fbf6c1c019f | |
parent | ff172a9222a84b59723d81ac2be20641658b17e0 (diff) |
fix(federation): Log and test last read message
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r-- | lib/Federation/CloudFederationProviderTalk.php | 4 | ||||
-rw-r--r-- | tests/integration/features/bootstrap/FeatureContext.php | 3 | ||||
-rw-r--r-- | tests/integration/features/federation/chat.feature | 20 |
3 files changed, 17 insertions, 10 deletions
diff --git a/lib/Federation/CloudFederationProviderTalk.php b/lib/Federation/CloudFederationProviderTalk.php index 43552b349..2788300a0 100644 --- a/lib/Federation/CloudFederationProviderTalk.php +++ b/lib/Federation/CloudFederationProviderTalk.php @@ -415,6 +415,10 @@ class CloudFederationProviderTalk implements ICloudFederationProvider { return []; } + $this->logger->debug('Setting unread info for local federated user ' . $invite->getUserId() . ' in ' . $room->getToken() . ' to ' . json_encode($notification['unreadInfo']), [ + 'app' => 'spreed-federation', + ]); + $this->participantService->updateUnreadInfoForProxyParticipant( $participant, $notification['unreadInfo']['unreadMessages'], diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php index afc431ed9..00018426b 100644 --- a/tests/integration/features/bootstrap/FeatureContext.php +++ b/tests/integration/features/bootstrap/FeatureContext.php @@ -460,6 +460,9 @@ class FeatureContext implements Context, SnippetAcceptingContext { if (isset($expectedRoom['lastMessage'])) { $data['lastMessage'] = $room['lastMessage'] ? $room['lastMessage']['message'] : ''; } + if (isset($expectedRoom['lastReadMessage'])) { + $data['lastReadMessage'] = self::$messageIdToText[(int) $room['lastReadMessage']] ?? (!$room['lastReadMessage'] ? 'ZERO': 'UNKNOWN_MESSAGE'); + } if (isset($expectedRoom['unreadMessages'])) { $data['unreadMessages'] = (int) $room['unreadMessages']; } diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index d600b7e04..b56078ce2 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -147,26 +147,26 @@ Feature: federation/chat | id | name | type | remoteServer | remoteToken | | room | room | 2 | LOCAL | room | Then user "participant2" is participant of the following rooms (v4) - | id | type | unreadMessages | unreadMention | unreadMentionDirect | - | room | 2 | 0 | 0 | 0 | + | id | type | lastReadMessage | unreadMessages | unreadMention | unreadMentionDirect | + | room | 2 | UNKNOWN_MESSAGE | 0 | 0 | 0 | And user "participant1" sends message "Message 1" to room "room" with 201 And user "participant1" sends message "Message 2" to room "room" with 201 When user "participant2" marks room "LOCAL::room" as unread with 200 (v1) Then user "participant2" is participant of the following rooms (v4) - | id | type | unreadMessages | unreadMention | unreadMentionDirect | - | room | 2 | 1 | 0 | 0 | + | id | type | lastReadMessage | unreadMessages | unreadMention | unreadMentionDirect | + | room | 2 | Message 1 | 1 | 0 | 0 | When user "participant2" reads message "NULL" in room "LOCAL::room" with 200 (v1) Then user "participant2" is participant of the following rooms (v4) - | id | type | unreadMessages | unreadMention | unreadMentionDirect | - | room | 2 | 0 | 0 | 0 | + | id | type | lastReadMessage | unreadMessages | unreadMention | unreadMentionDirect | + | room | 2 | Message 2 | 0 | 0 | 0 | When user "participant2" reads message "Message 1" in room "LOCAL::room" with 200 (v1) Then user "participant2" is participant of the following rooms (v4) - | id | type | unreadMessages | unreadMention | unreadMentionDirect | - | room | 2 | 1 | 0 | 0 | + | id | type | lastReadMessage | unreadMessages | unreadMention | unreadMentionDirect | + | room | 2 | Message 1 | 1 | 0 | 0 | When user "participant2" reads message "Message 2" in room "LOCAL::room" with 200 (v1) Then user "participant2" is participant of the following rooms (v4) - | id | type | unreadMessages | unreadMention | unreadMentionDirect | - | room | 2 | 0 | 0 | 0 | + | id | type | lastReadMessage | unreadMessages | unreadMention | unreadMentionDirect | + | room | 2 | Message 2 | 0 | 0 | 0 | Scenario: Error handling of chatting (posting a too long message) Given the following "spreed" app config is set |