From b57196179f8c093eafbd6a8a680c182c95c90bee Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Sat, 26 Feb 2022 00:21:47 +0100 Subject: [PATCH] Only calculate the room name once instead of loading all participants Signed-off-by: Joas Schilling --- lib/Activity/Listener.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/Activity/Listener.php b/lib/Activity/Listener.php index 232225b6826..57410417ff6 100644 --- a/lib/Activity/Listener.php +++ b/lib/Activity/Listener.php @@ -232,6 +232,11 @@ public function generateInvitationActivity(Room $room, array $participants): voi return; } + // We know the new participant is in the room, + // so skip loading them just to make sure they can read it. + // Must be overwritten later on for one-to-one chats. + $roomName = $room->getDisplayName($actorId); + foreach ($participants as $participant) { if ($participant['actorType'] !== Attendee::ACTOR_USERS) { // No user => no activity @@ -244,7 +249,10 @@ public function generateInvitationActivity(Room $room, array $participants): voi } try { - $roomName = $room->getDisplayName($participant['actorId']); + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { + // Overwrite the room name with the other participant + $roomName = $room->getDisplayName($participant['actorId']); + } $event ->setObject('room', $room->getId(), $roomName) ->setSubject('invitation', [