|
|
|
@ -197,7 +197,7 @@ class RoomController extends OCSController { |
|
|
|
|
|
|
|
$roomData = array_merge($roomData, [ |
|
|
|
'name' => $room->getName(), |
|
|
|
'displayName' => $room->getName(), |
|
|
|
'displayName' => $room->getDisplayName($currentParticipant->getUser()), |
|
|
|
'objectType' => $room->getObjectType(), |
|
|
|
'objectId' => $room->getObjectId(), |
|
|
|
'participantType' => $currentParticipant->getParticipantType(), |
|
|
|
@ -219,11 +219,6 @@ class RoomController extends OCSController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
if ($room->getObjectType() === 'share:password') { |
|
|
|
// FIXME use an event
|
|
|
|
$roomData['displayName'] = $this->l10n->t('Password request: %s', [$room->getName()]); |
|
|
|
} |
|
|
|
|
|
|
|
$currentUser = $this->userManager->get($currentParticipant->getUser()); |
|
|
|
if ($currentUser instanceof IUser) { |
|
|
|
$unreadSince = $this->chatManager->getUnreadMarker($room, $currentUser); |
|
|
|
@ -285,76 +280,6 @@ class RoomController extends OCSController { |
|
|
|
'lastMessage' => $lastMessage, |
|
|
|
]); |
|
|
|
|
|
|
|
if (!$currentParticipant->isGuest()) { |
|
|
|
unset($participantList[$currentParticipant->getUser()]); |
|
|
|
$numOtherParticipants = \count($participantList); |
|
|
|
$numGuestParticipants = $numActiveGuests; |
|
|
|
} else { |
|
|
|
$numOtherParticipants = \count($participantList); |
|
|
|
$numGuestParticipants = $numActiveGuests - 1; |
|
|
|
} |
|
|
|
|
|
|
|
$guestString = ''; |
|
|
|
switch ($room->getType()) { |
|
|
|
case Room::ONE_TO_ONE_CALL: |
|
|
|
// As name of the room use the name of the other person participating
|
|
|
|
if ($numOtherParticipants === 1) { |
|
|
|
// Only one other participant
|
|
|
|
reset($participantList); |
|
|
|
$roomData['name'] = key($participantList); |
|
|
|
$roomData['displayName'] = $participantList[$roomData['name']]['name']; |
|
|
|
} else { |
|
|
|
// Invalid user count, there must be exactly 2 users in each one2one room
|
|
|
|
$this->logger->warning('one2one room found with invalid participant count. Leaving room for everyone', [ |
|
|
|
'app' => 'spreed', |
|
|
|
]); |
|
|
|
$room->deleteRoom(); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
/** @noinspection PhpMissingBreakStatementInspection */ |
|
|
|
case Room::PUBLIC_CALL: |
|
|
|
if ($numGuestParticipants) { |
|
|
|
if ($currentParticipant->isGuest()) { |
|
|
|
$guestString = $this->l10n->n('%n other guest', '%n other guests', $numGuestParticipants); |
|
|
|
} else { |
|
|
|
$guestString = $this->l10n->n('%n guest', '%n guests', $numGuestParticipants); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// no break;
|
|
|
|
|
|
|
|
case Room::GROUP_CALL: |
|
|
|
if ($room->getName() === '') { |
|
|
|
// As name of the room use the names of the other participants
|
|
|
|
$participantList = array_map(function($participant) { |
|
|
|
return $participant['name']; |
|
|
|
}, $participantList); |
|
|
|
if ($currentParticipant->isGuest()) { |
|
|
|
$participantList[] = $this->l10n->t('You'); |
|
|
|
} else if ($numOtherParticipants === 0) { |
|
|
|
$participantList = [$this->l10n->t('You')]; |
|
|
|
} |
|
|
|
|
|
|
|
if ($guestString !== '') { |
|
|
|
$participantList[] = $guestString; |
|
|
|
} |
|
|
|
|
|
|
|
$roomData['displayName'] = implode($this->l10n->t(', '), $participantList); |
|
|
|
} |
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
// Invalid room type
|
|
|
|
$this->logger->warning('Invalid room type found. Leaving room for everyone', [ |
|
|
|
'app' => 'spreed', |
|
|
|
]); |
|
|
|
$room->deleteRoom(); |
|
|
|
throw new RoomNotFoundException('The room type is unknown'); |
|
|
|
} |
|
|
|
|
|
|
|
$roomData['guestList'] = $guestString; |
|
|
|
|
|
|
|
return $roomData; |
|
|
|
} |
|
|
|
|
|
|
|
@ -450,7 +375,7 @@ class RoomController extends OCSController { |
|
|
|
return new DataResponse([ |
|
|
|
'token' => $room->getToken(), |
|
|
|
'name' => $room->getName(), |
|
|
|
'displayName' => $targetUser->getDisplayName(), |
|
|
|
'displayName' => $room->getDisplayName($currentUser->getUID()), |
|
|
|
], Http::STATUS_CREATED); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -500,7 +425,7 @@ class RoomController extends OCSController { |
|
|
|
return new DataResponse([ |
|
|
|
'token' => $room->getToken(), |
|
|
|
'name' => $room->getName(), |
|
|
|
'displayName' => $room->getName(), |
|
|
|
'displayName' => $room->getDisplayName($currentUser->getUID()), |
|
|
|
], Http::STATUS_CREATED); |
|
|
|
} |
|
|
|
|
|
|
|
@ -512,6 +437,11 @@ class RoomController extends OCSController { |
|
|
|
* @return DataResponse |
|
|
|
*/ |
|
|
|
protected function createEmptyRoom(string $roomName, bool $public = true): DataResponse { |
|
|
|
$roomName = trim($roomName); |
|
|
|
if ($roomName === '') { |
|
|
|
return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
|
|
} |
|
|
|
|
|
|
|
$currentUser = $this->userManager->get($this->userId); |
|
|
|
|
|
|
|
if (!$currentUser instanceof IUser) { |
|
|
|
@ -532,7 +462,7 @@ class RoomController extends OCSController { |
|
|
|
return new DataResponse([ |
|
|
|
'token' => $room->getToken(), |
|
|
|
'name' => $room->getName(), |
|
|
|
'displayName' => $room->getName(), |
|
|
|
'displayName' => $room->getDisplayName($currentUser->getUID()), |
|
|
|
], Http::STATUS_CREATED); |
|
|
|
} |
|
|
|
|
|
|
|
@ -628,7 +558,9 @@ class RoomController extends OCSController { |
|
|
|
return new DataResponse([], Http::STATUS_FORBIDDEN); |
|
|
|
} |
|
|
|
|
|
|
|
if (strlen($roomName) > 200) { |
|
|
|
$roomName = trim($roomName); |
|
|
|
|
|
|
|
if ($roomName === '' || strlen($roomName) > 200) { |
|
|
|
return new DataResponse([], Http::STATUS_BAD_REQUEST); |
|
|
|
} |
|
|
|
|
|
|
|
|