diff --git a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php index 4ceb5a4a311..a601166d14b 100644 --- a/lib/Federation/Proxy/TalkV1/Controller/ChatController.php +++ b/lib/Federation/Proxy/TalkV1/Controller/ChatController.php @@ -371,14 +371,14 @@ public function deleteMessage(Room $room, Participant $participant, int $message * * 200: List of mention suggestions returned */ - public function setReadMarker(Room $room, Participant $participant, string $responseFormat, int $lastReadMessage): DataResponse { + public function setReadMarker(Room $room, Participant $participant, string $responseFormat, ?int $lastReadMessage): DataResponse { $proxy = $this->proxy->post( $participant->getAttendee()->getInvitedCloudId(), $participant->getAttendee()->getAccessToken(), $room->getRemoteServer() . '/ocs/v2.php/apps/spreed/api/v1/chat/' . $room->getRemoteToken() . '/read', - [ + $lastReadMessage !== null ? [ 'lastReadMessage' => $lastReadMessage, - ], + ] : [], ); /** @var TalkRoom $data */ diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 0849772cd0f..0c12fb3f0a2 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -126,6 +126,48 @@ Feature: federation/chat | room | users | participant2 | participant2-displayname | Message deleted by you | {"actor":{"type":"user","id":"participant2","name":"participant2-displayname"}} | Message deleted by author | | room | federated_users | participant1@{$BASE_URL} | participant1-displayname | Message deleted by author | {"actor":{"type":"user","id":"participant1","name":"participant1-displayname","server":"{$BASE_URL}"}} | | + Scenario: Read marker checking + Given the following "spreed" app config is set + | federation_enabled | yes | + Given user "participant1" creates room "room" (v4) + | roomType | 2 | + | roomName | room | + And user "participant1" adds federated_user "participant2" to room "room" with 200 (v4) + And user "participant1" adds federated_user "participant3" to room "room" with 200 (v4) + And user "participant2" has the following invitations (v1) + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) + | id | name | type | remoteServer | remoteToken | + | room | room | 2 | LOCAL | room | + 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 | + | 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 | + 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 | + 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 | + 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 | + 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 | + Scenario: Error handling of chatting (posting a too long message) Given the following "spreed" app config is set | federation_enabled | yes |