diff options
author | Joas Schilling <213943+nickvergessen@users.noreply.github.com> | 2024-03-15 11:27:48 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-03-15 11:27:48 +0100 |
commit | 10dfbd3d1b6512c75938c24df45cc0f24e49b1d2 (patch) | |
tree | 4c79eadeedc91ed8d10eb76aa917666d69f8d4d0 | |
parent | fa90615dc506d32ef7f4f335a4b09223239ef64d (diff) | |
parent | df2d18095fbc5a18f6586b404f93823475f71050 (diff) |
Merge pull request #11810 from nextcloud/bugfix/noid/improve-logging-for-unread-info
fix(federation): Log and test last read message
-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 |