diff options
author | Daniel Calviño Sánchez <danxuliu@gmail.com> | 2020-11-12 22:17:47 +0300 |
---|---|---|
committer | Joas Schilling <coding@schilljs.com> | 2020-12-08 14:58:48 +0300 |
commit | e8e4accb82cdf7bf25cda32a01ee7642b9882943 (patch) | |
tree | e506092d057f7251b2800272bd3059828c26ef3e /lib/Controller | |
parent | c5cf6be4a318ccab97f4f65f106cc20ede93a241 (diff) |
Return description with the rest of the conversation data
As the description is not typically needed in the conversation list, it
could be potentially "large" and the conversation list is fetched
frequently only a hash of the description is returned in that case. The
exception is when the description is empty, in which case an empty value
is returned, instead of the value of "sha1('')".
If only a single conversation is fetched the actual description is
always returned.
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/RoomController.php | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php index c4d3f7748..d2a957002 100644 --- a/lib/Controller/RoomController.php +++ b/lib/Controller/RoomController.php @@ -198,10 +198,13 @@ class RoomController extends AEnvironmentAwareController { $rooms = $this->manager->getRoomsForUser($this->userId, true); + $isSIPBridgeRequest = false; + $isFullRoomListRequest = true; + $return = []; foreach ($rooms as $room) { try { - $return[] = $this->formatRoom($room, $room->getParticipant($this->userId)); + $return[] = $this->formatRoom($room, $room->getParticipant($this->userId), $isSIPBridgeRequest, $isFullRoomListRequest); } catch (RoomNotFoundException $e) { } catch (\RuntimeException $e) { } @@ -295,12 +298,13 @@ class RoomController extends AEnvironmentAwareController { * @param Room $room * @param Participant|null $currentParticipant * @param bool $isSIPBridgeRequest + * @param bool $isFullRoomListRequest * @return array * @throws RoomNotFoundException */ - protected function formatRoom(Room $room, ?Participant $currentParticipant, bool $isSIPBridgeRequest = false): array { + protected function formatRoom(Room $room, ?Participant $currentParticipant, bool $isSIPBridgeRequest = false, bool $isFullRoomListRequest = false): array { if ($this->getAPIVersion() >= 2) { - return $this->formatRoomV2andV3($room, $currentParticipant, $isSIPBridgeRequest); + return $this->formatRoomV2andV3($room, $currentParticipant, $isSIPBridgeRequest, $isFullRoomListRequest); } return $this->formatRoomV1($room, $currentParticipant); @@ -507,10 +511,11 @@ class RoomController extends AEnvironmentAwareController { * @param Room $room * @param Participant|null $currentParticipant * @param bool $isSIPBridgeRequest + * @param bool $isFullRoomListRequest * @return array * @throws RoomNotFoundException */ - protected function formatRoomV2andV3(Room $room, ?Participant $currentParticipant, bool $isSIPBridgeRequest = false): array { + protected function formatRoomV2andV3(Room $room, ?Participant $currentParticipant, bool $isSIPBridgeRequest = false, bool $isFullRoomListRequest = false): array { $roomData = [ 'id' => $room->getId(), 'token' => $room->getToken(), @@ -548,6 +553,7 @@ class RoomController extends AEnvironmentAwareController { 'attendeeId' => 0, 'canEnableSIP' => false, 'attendeePin' => '', + 'description' => '', ]); } @@ -616,6 +622,7 @@ class RoomController extends AEnvironmentAwareController { 'actorType' => $attendee->getActorType(), 'actorId' => $attendee->getActorId(), 'attendeeId' => $attendee->getId(), + 'description' => ($isFullRoomListRequest && !empty($room->getDescription())) ? sha1($room->getDescription()) : $room->getDescription(), ]); } |