From 89fb90983e3b1ebde1d9026bfe4ec27e415b3c05 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 20 Jan 2025 15:35:55 +0100 Subject: [PATCH 1/9] fix(reactions): wrong attribution for federated reactions Signed-off-by: Anna Larch --- lib/Notification/Notifier.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/Notification/Notifier.php b/lib/Notification/Notifier.php index aff49bd1998..a706d45e826 100644 --- a/lib/Notification/Notifier.php +++ b/lib/Notification/Notifier.php @@ -537,18 +537,26 @@ protected function parseChatMessage(INotification $notification, Room $room, Par } } elseif ($subjectParameters['userType'] === Attendee::ACTOR_FEDERATED_USERS) { try { - $cloudId = $this->cloudIdManager->resolveCloudId($message->getActorId()); + $cloudId = $this->cloudIdManager->resolveCloudId($subjectParameters['userId']); + $cloudParticipant = $this->participantService->getParticipantByActor($room, Attendee::ACTOR_FEDERATED_USERS, $subjectParameters['userId']); $richSubjectUser = [ 'type' => 'user', 'id' => $cloudId->getUser(), - 'name' => $message->getActorDisplayName(), + 'name' => $cloudParticipant->getAttendee()->getDisplayName(), + 'server' => $cloudId->getRemote(), + ]; + } catch (ParticipantNotFoundException) { + $richSubjectUser = [ + 'type' => 'user', + 'id' => $cloudId->getUser(), + 'name' => $cloudId->getDisplayId(), 'server' => $cloudId->getRemote(), ]; } catch (\InvalidArgumentException) { $richSubjectUser = [ 'type' => 'highlight', - 'id' => $message->getActorId(), - 'name' => $message->getActorId(), + 'id' => $subjectParameters['userId'], + 'name' => $subjectParameters['userId'], ]; } } elseif ($subjectParameters['userType'] === Attendee::ACTOR_BOTS) { From 4722efa3d3184506bb1b2b93718a5a17a27e3265 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 20 Jan 2025 16:56:45 +0100 Subject: [PATCH 2/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 5550308477d..b3c15f410f2 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -245,7 +245,7 @@ Feature: federation/chat And using server "REMOTE" And user "participant2" has the following invitations (v1) | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | id | name | type | remoteServer | remoteToken | | LOCAL::room | room | 2 | LOCAL | room | From b149b33b9baa497b51b7ccebf52fac6be2133e62 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 20 Jan 2025 17:13:02 +0100 Subject: [PATCH 3/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index b3c15f410f2..18381217ae2 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -301,7 +301,7 @@ Feature: federation/chat And using server "REMOTE" And user "participant2" has the following invitations (v1) | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | id | name | type | remoteServer | remoteToken | | LOCAL::room | room | 3 | LOCAL | room | From 8a9449e1b8852dec01514df73046001e7de17157 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Mon, 20 Jan 2025 17:15:24 +0100 Subject: [PATCH 4/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 18381217ae2..5550308477d 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -245,7 +245,7 @@ Feature: federation/chat And using server "REMOTE" And user "participant2" has the following invitations (v1) | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | + | 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 | | LOCAL::room | room | 2 | LOCAL | room | @@ -301,7 +301,7 @@ Feature: federation/chat And using server "REMOTE" And user "participant2" has the following invitations (v1) | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | + | 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 | | LOCAL::room | room | 3 | LOCAL | room | From 1d295c42b0f1391f128c6c501d36f534f236ce86 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 21 Jan 2025 12:19:59 +0100 Subject: [PATCH 5/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 4 ++-- tests/integration/features/federation/reminder.feature | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 5550308477d..025fceb1abe 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -244,8 +244,8 @@ Feature: federation/chat And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4) And using server "REMOTE" And user "participant2" has the following invitations (v1) - | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | id | name | type | remoteServer | remoteToken | | LOCAL::room | room | 2 | LOCAL | room | diff --git a/tests/integration/features/federation/reminder.feature b/tests/integration/features/federation/reminder.feature index 1656b092040..cc46ae4d935 100644 --- a/tests/integration/features/federation/reminder.feature +++ b/tests/integration/features/federation/reminder.feature @@ -50,7 +50,7 @@ Feature: federation/reminder And using server "REMOTE" And user "participant2" has the following notifications | app | object_type | object_id | subject | - | spreed | reminder | LOCAL::room/Message 1 | Reminder: participant1-displayname in conversation room | + | spreed | reminder | LOCAL::room/Message 1 | Reminder: participant1@localhost:8080 in conversation room | # Participant1 sets timestamp to past so it should trigger now When using server "LOCAL" And user "participant1" sets reminder for message "Message 2" in room "room" for time 1234567 with 201 (v1) From 5fe4794e713f2dd73814e234cb69bfdd9ee63d6a Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 21 Jan 2025 12:31:06 +0100 Subject: [PATCH 6/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 7 +++++-- tests/integration/features/federation/reminder.feature | 5 ++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 025fceb1abe..b441d6805bc 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -244,8 +244,11 @@ Feature: federation/chat And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4) And using server "REMOTE" And user "participant2" has the following invitations (v1) - | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + # This is the previous version of the line. localhost:8080 is not the expected result but the username + # is resolved to it because of missing display name resolution for federation. Revert this when it's been fixed + #| 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 | | LOCAL::room | room | 2 | LOCAL | room | diff --git a/tests/integration/features/federation/reminder.feature b/tests/integration/features/federation/reminder.feature index cc46ae4d935..a82d4502230 100644 --- a/tests/integration/features/federation/reminder.feature +++ b/tests/integration/features/federation/reminder.feature @@ -49,8 +49,11 @@ Feature: federation/reminder | app | object_type | object_id | subject | And using server "REMOTE" And user "participant2" has the following notifications - | app | object_type | object_id | subject | + | app | object_type | object_id | subject | | spreed | reminder | LOCAL::room/Message 1 | Reminder: participant1@localhost:8080 in conversation room | + # This is the previous version of the line. localhost:8080 is not the expected result but the username + # is resolved to it because of missing display name resolution for federation. Revert this when it's been fixed + # | spreed | reminder | LOCAL::room/Message 1 | Reminder: participant1-displayname in conversation room | # Participant1 sets timestamp to past so it should trigger now When using server "LOCAL" And user "participant1" sets reminder for message "Message 2" in room "room" for time 1234567 with 201 (v1) From 7fc468b311dab6e6d78098c2f31b666e5a4e63d0 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 21 Jan 2025 12:46:43 +0100 Subject: [PATCH 7/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index b441d6805bc..8c39c4adba9 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -244,11 +244,8 @@ Feature: federation/chat And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4) And using server "REMOTE" And user "participant2" has the following invitations (v1) - | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | - # This is the previous version of the line. localhost:8080 is not the expected result but the username - # is resolved to it because of missing display name resolution for federation. Revert this when it's been fixed - #| LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | id | name | type | remoteServer | remoteToken | | LOCAL::room | room | 2 | LOCAL | room | @@ -279,8 +276,8 @@ Feature: federation/chat Then using server "REMOTE" Then user "participant2" has the following notifications | app | object_type | object_id | subject | message | - | spreed | chat | LOCAL::room/Hi @all bye | participant1-displayname mentioned everyone in conversation room | Hi room bye | - | spreed | chat | LOCAL::room/Hi @"federated_user/participant2@{$REMOTE_URL}" bye | participant1-displayname mentioned you in conversation room | Hi @participant2-displayname bye | + | spreed | chat | LOCAL::room/Hi @all bye | participant1@localhost:8080 mentioned everyone in conversation room | Hi room bye | + | spreed | chat | LOCAL::room/Hi @"federated_user/participant2@{$REMOTE_URL}" bye | participant1@localhost:8080 mentioned you in conversation room | Hi @participant2-displayname bye | | spreed | chat | LOCAL::room/Message 1-1 | participant1-displayname replied to your message in conversation room | Message 1-1 | When next message request has the following parameters set | timeout | 0 | From d4e44b34f4be0e7ad08422d770b8ee5d7b4189f1 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 21 Jan 2025 13:00:51 +0100 Subject: [PATCH 8/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 8c39c4adba9..6811c942f34 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -300,8 +300,8 @@ Feature: federation/chat And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4) And using server "REMOTE" And user "participant2" has the following invitations (v1) - | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1-displayname | + | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | + | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | And user "participant2" accepts invite to room "room" of server "LOCAL" with 200 (v1) | id | name | type | remoteServer | remoteToken | | LOCAL::room | room | 3 | LOCAL | room | From 8c9867ea669fdb5092df0a82145e30dce1f3ea66 Mon Sep 17 00:00:00 2001 From: Anna Larch Date: Tue, 21 Jan 2025 14:11:50 +0100 Subject: [PATCH 9/9] fixup! fix(reactions): wrong attribution for federated reactions --- tests/integration/features/federation/chat.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/integration/features/federation/chat.feature b/tests/integration/features/federation/chat.feature index 6811c942f34..8c39c4adba9 100644 --- a/tests/integration/features/federation/chat.feature +++ b/tests/integration/features/federation/chat.feature @@ -300,8 +300,8 @@ Feature: federation/chat And user "participant1" adds federated_user "participant2@REMOTE" to room "room" with 200 (v4) And using server "REMOTE" And user "participant2" has the following invitations (v1) - | remoteServerUrl | remoteToken | state | inviterCloudId | inviterDisplayName | - | LOCAL | room | 0 | participant1@http://localhost:8080 | participant1@localhost:8080 | + | 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 | | LOCAL::room | room | 3 | LOCAL | room |