diff options
author | Joas Schilling <coding@schilljs.com> | 2024-03-06 12:31:22 +0100 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2024-03-06 21:05:00 +0100 |
commit | 578b1d5873784490daed3d47540ae30781581c8d (patch) | |
tree | 082f86b3e5bb20754cb6e72647ded0a5c08c036d /lib | |
parent | 1a26108cdd7ae6680f22ee51b8763f1dea0850ed (diff) |
feat(federation): Allow to convert a single type and id
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Federation/Proxy/TalkV1/UserConverter.php | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/lib/Federation/Proxy/TalkV1/UserConverter.php b/lib/Federation/Proxy/TalkV1/UserConverter.php index debc01883..d58aa8e40 100644 --- a/lib/Federation/Proxy/TalkV1/UserConverter.php +++ b/lib/Federation/Proxy/TalkV1/UserConverter.php @@ -45,6 +45,26 @@ class UserConverter { ) { } + /** + * @return array{type: string, id: string} + */ + public function convertTypeAndId(Room $room, string $type, string $id): array { + if ($type === Attendee::ACTOR_USERS) { + $type = Attendee::ACTOR_FEDERATED_USERS; + $id .= '@' . $room->getRemoteServer(); + } elseif ($type === Attendee::ACTOR_FEDERATED_USERS) { + $localParticipants = $this->getLocalParticipants($room); + if (isset($localParticipants[$id])) { + $local = $localParticipants[$id]; + + $type = Attendee::ACTOR_USERS; + $id = $local['userId']; + } + } + + return ['type' => $type, 'id' => $id]; + } + public function convertAttendee(Room $room, array $entry, string $typeField, string $idField, string $displayNameField): array { if (!isset($entry[$typeField])) { return $entry; @@ -89,7 +109,7 @@ class UserConverter { return $parameter; } - protected function convertMessageParameters(Room $room, array $message): array { + public function convertMessageParameters(Room $room, array $message): array { $message['messageParameters'] = array_map( fn (array $message): array => $this->convertMessageParameter($room, $message), $message['messageParameters'] |