From bc1e3700b8870be554a2302bac0e5ddcdd7f8b72 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Wed, 20 Mar 2024 12:54:32 +0100 Subject: [PATCH] fix(federation): Fix matching the current user only when there is no server attribute Signed-off-by: Joas Schilling --- lib/Chat/Parser/SystemMessage.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Chat/Parser/SystemMessage.php b/lib/Chat/Parser/SystemMessage.php index 84185708f..55818a123 100644 --- a/lib/Chat/Parser/SystemMessage.php +++ b/lib/Chat/Parser/SystemMessage.php @@ -161,7 +161,8 @@ class SystemMessage implements IEventListener { $currentActorId = $participant->getAttendee()->getActorId(); $currentUserIsActor = $parsedParameters['actor']['type'] === 'user' && $participant->getAttendee()->getActorType() === Attendee::ACTOR_USERS && - $currentActorId === $parsedParameters['actor']['id']; + $currentActorId === $parsedParameters['actor']['id'] && + empty($parsedParameters['actor']['server']); } else { $currentActorType = $participant->getAttendee()->getActorType(); $currentActorId = $participant->getAttendee()->getActorId(); @@ -365,7 +366,9 @@ class SystemMessage implements IEventListener { $parsedMessage = $this->l->t('{actor} invited {federated_user}'); if ($currentUserIsActor) { $parsedMessage = $this->l->t('You invited {federated_user}'); - if ($parsedParameters['federated_user']['id'] === $parsedParameters['actor']['id']) { + if (isset($parsedParameters['federated_user']['server'], $parsedParameters['actor']['server']) + && $parsedParameters['federated_user']['id'] === $parsedParameters['actor']['id'] + && $parsedParameters['federated_user']['server'] === $parsedParameters['actor']['server']) { $parsedMessage = $this->l->t('You accepted the invitation'); } } elseif ($this->isCurrentParticipantChangedUser($currentActorType, $currentActorId, $parsedParameters['federated_user'])) { @@ -375,7 +378,9 @@ class SystemMessage implements IEventListener { } } elseif ($cliIsActor) { $parsedMessage = $this->l->t('An administrator invited {federated_user}'); - } elseif ($parsedParameters['federated_user']['id'] === $parsedParameters['actor']['id']) { + } elseif (isset($parsedParameters['federated_user']['server'], $parsedParameters['actor']['server']) + && $parsedParameters['federated_user']['id'] === $parsedParameters['actor']['id'] + && $parsedParameters['federated_user']['server'] === $parsedParameters['actor']['server']) { $parsedMessage = $this->l->t('{federated_user} accepted the invitation'); } } elseif ($message === 'federated_user_removed') {