Skip to content

Commit

Permalink
Merge pull request #8925 from nextcloud/bugfix/noid/show-names-when-l…
Browse files Browse the repository at this point in the history
…isting-breakout-rooms

Show breakout room names when listing breakout rooms
  • Loading branch information
marcoambrosini authored Mar 2, 2023
2 parents c9e9417 + 4210197 commit fd1f8b9
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 8 deletions.
5 changes: 4 additions & 1 deletion lib/Controller/BreakoutRoomController.php
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,10 @@ protected function formatMultipleRooms(array $rooms): array {
$this->getResponseFormat(),
[],
$room,
$this->participantService->getParticipant($room, $this->userId)
$this->participantService->getParticipant($room, $this->userId),
[],
false,
true
);
} catch (ParticipantNotFoundException $e) {
}
Expand Down
15 changes: 12 additions & 3 deletions lib/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -813,14 +813,18 @@ public function getRoomByObject(string $objectType, string $objectId): Room {
* @param string $objectId
* @return Room[]
*/
public function getMultipleRoomsByObject(string $objectType, string $objectId): array {
public function getMultipleRoomsByObject(string $objectType, string $objectId, bool $orderById = false): array {
$query = $this->db->getQueryBuilder();
$helper = new SelectHelper();
$helper->selectRoomsTable($query);
$query->from('talk_rooms', 'r')
->where($query->expr()->eq('r.object_type', $query->createNamedParameter($objectType)))
->andWhere($query->expr()->eq('r.object_id', $query->createNamedParameter($objectId)));

if ($orderById) {
$query->orderBy('id', 'ASC');
}

$result = $query->executeQuery();
$rooms = [];
while ($row = $result->fetch()) {
Expand Down Expand Up @@ -1044,18 +1048,23 @@ public function createRemoteRoom(int $type, string $name, string $remoteToken, s
]);
}

public function resolveRoomDisplayName(Room $room, string $userId): string {
public function resolveRoomDisplayName(Room $room, string $userId, bool $forceName = false): string {
if ($room->getObjectType() === 'share:password') {
return $this->l->t('Password request: %s', [$room->getName()]);
}

if ($room->getType() === Room::TYPE_CHANGELOG) {
return $this->l->t('Talk updates ✅');
}

if ($forceName) {
return $room->getName();
}

if ($userId === '' && $room->getType() !== Room::TYPE_PUBLIC) {
return $this->l->t('Private conversation');
}


if ($room->getType() !== Room::TYPE_ONE_TO_ONE && $room->getName() === '') {
/** @var RoomService $roomService */
$roomService = Server::get(RoomService::class);
Expand Down
4 changes: 2 additions & 2 deletions lib/Room.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ public function getSecondParticipant(string $userId): string {
return $this->getName();
}

public function getDisplayName(string $userId): string {
return $this->manager->resolveRoomDisplayName($this, $userId);
public function getDisplayName(string $userId, bool $forceName = false): string {
return $this->manager->resolveRoomDisplayName($this, $userId, $forceName);
}

public function getDescription(): string {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/BreakoutRoomService.php
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ public function getBreakoutRooms(Room $parent, Participant $participant): array
throw new \InvalidArgumentException('status');
}

$breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken());
$breakoutRooms = $this->manager->getMultipleRoomsByObject(BreakoutRoom::PARENT_OBJECT_TYPE, $parent->getToken(), true);

$returnAll = $participant->hasModeratorPermissions() || $parent->getBreakoutRoomMode() === BreakoutRoom::MODE_FREE;
if (!$returnAll) {
Expand Down
2 changes: 1 addition & 1 deletion lib/Service/RoomFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ public function formatRoomV4(
) {
return array_merge($roomData, [
'name' => $room->getName(),
'displayName' => $room->getDisplayName($isSIPBridgeRequest || $this->userId === null ? '' : $this->userId),
'displayName' => $room->getDisplayName($isListingBreakoutRooms || $isSIPBridgeRequest || $this->userId === null ? '' : $this->userId, $isListingBreakoutRooms || $isSIPBridgeRequest),
'objectType' => $room->getObjectType(),
'objectId' => $room->getObjectId(),
'readOnly' => $room->getReadOnly(),
Expand Down

0 comments on commit fd1f8b9

Please sign in to comment.