Skip to content

Commit

Permalink
Merge pull request #11871 from nextcloud/bugfix/noid/fix-current-user…
Browse files Browse the repository at this point in the history
…-matching-federated-user

fix(federation): Fix matching the current user only when there is no …
  • Loading branch information
nickvergessen authored Mar 21, 2024
2 parents 4c8044f + bc1e370 commit c1644fc
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/Chat/Parser/SystemMessage.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,8 @@ protected function parseMessage(Message $chatMessage): void {
$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();
Expand Down Expand Up @@ -365,7 +366,9 @@ protected function parseMessage(Message $chatMessage): void {
$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'])) {
Expand All @@ -375,7 +378,9 @@ protected function parseMessage(Message $chatMessage): void {
}
} 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') {
Expand Down

0 comments on commit c1644fc

Please sign in to comment.