summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-03-27 10:29:03 +0100
committerJoas Schilling <coding@schilljs.com>2024-03-27 10:50:27 +0100
commit50e55d20a42877d28c7624d6650a2debad6bd170 (patch)
tree3a7c48d07c37767745a9959e22436fed671212bf
parent48634fe8d24549d7697582dc6a676472463256d1 (diff)
fix(federation): Don't double convert the actor info in the last message
The PCM cache is already converted, so converting again on rendering, would create a conflict if there is a user1 from host and proxy in the room. Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--lib/Service/RoomFormatter.php2
-rw-r--r--tests/integration/features/bootstrap/FeatureContext.php8
-rw-r--r--tests/integration/features/federation/chat.feature28
3 files changed, 37 insertions, 1 deletions
diff --git a/lib/Service/RoomFormatter.php b/lib/Service/RoomFormatter.php
index 90a1c20b1..4430ccc39 100644
--- a/lib/Service/RoomFormatter.php
+++ b/lib/Service/RoomFormatter.php
@@ -394,7 +394,7 @@ class RoomFormatter {
$room->getRemoteToken(),
$room->getLastMessageId(),
);
- $roomData['lastMessage'] = $this->userConverter->convertAttendee($room, $cachedMessage->jsonSerialize(), 'actorType', 'actorId', 'actorDisplayName');
+ $roomData['lastMessage'] = $cachedMessage->jsonSerialize();
} catch (DoesNotExistException) {
}
}
diff --git a/tests/integration/features/bootstrap/FeatureContext.php b/tests/integration/features/bootstrap/FeatureContext.php
index fb790f697..cc8ac557e 100644
--- a/tests/integration/features/bootstrap/FeatureContext.php
+++ b/tests/integration/features/bootstrap/FeatureContext.php
@@ -460,6 +460,14 @@ class FeatureContext implements Context, SnippetAcceptingContext {
if (isset($expectedRoom['lastMessage'])) {
$data['lastMessage'] = $room['lastMessage'] ? $room['lastMessage']['message'] : '';
}
+ if (isset($expectedRoom['lastMessageActorType'])) {
+ $data['lastMessageActorType'] = $room['lastMessage'] ? $room['lastMessage']['actorType'] : '';
+ }
+ if (isset($expectedRoom['lastMessageActorId'])) {
+ $data['lastMessageActorId'] = $room['lastMessage'] ? $room['lastMessage']['actorId'] : '';
+ $data['lastMessageActorId'] = str_replace(rtrim($this->baseUrl, '/'), '{$BASE_URL}', $data['lastMessageActorId']);
+ $data['lastMessageActorId'] = str_replace(rtrim($this->baseRemoteUrl, '/'), '{$REMOTE_URL}', $data['lastMessageActorId']);
+ }
if (isset($expectedRoom['lastReadMessage'])) {
$data['lastReadMessage'] = self::$messageIdToText[(int) $room['lastReadMessage']] ?? (!$room['lastReadMessage'] ? 'ZERO': 'UNKNOWN_MESSAGE');
}
diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature
index 08002cfce..82971dbeb 100644
--- a/tests/integration/features/federation/chat.feature
+++ b/tests/integration/features/federation/chat.feature
@@ -138,6 +138,34 @@ Feature: federation/chat
| id | type | lastMessage |
| room | 2 | Message deleted by author |
+ Scenario: Last message actor when the same user ID is present
+ 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 "participant1" to room "room" with 200 (v4)
+ And user "participant1" has the following invitations (v1)
+ | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName |
+ | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname |
+ And user "participant1" accepts invite to room "room" of server "LOCAL" with 200 (v1)
+ | id | name | type | remoteServer | remoteToken |
+ | room | room | 2 | LOCAL | room |
+ Then user "participant1" is participant of the following rooms (v4)
+ | id | type | lastMessage |
+ | room | 2 | {actor} invited you |
+ | room | 2 | {federated_user} accepted the invitation |
+ And user "participant1" sends message "Message 1" to room "room" with 201
+ Then user "participant1" is participant of the following rooms (v4)
+ | id | type | lastMessage | lastMessageActorType | lastMessageActorId |
+ | room | 2 | Message 1 | users | participant1 |
+ | room | 2 | Message 1 | federated_users | participant1@{$BASE_URL} |
+ When user "participant1" sends reply "Message 1-1" on message "Message 1" to room "LOCAL::room" with 201
+ Then user "participant1" is participant of the following rooms (v4)
+ | id | type | lastMessage | lastMessageActorType | lastMessageActorId |
+ | room | 2 | Message 1-1 | federated_users | participant1@{$REMOTE_URL} |
+ | room | 2 | Message 1-1 | users | participant1 |
+
Scenario: Read marker checking
Given the following "spreed" app config is set
| federation_enabled | yes |