Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/spreed.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVincent Petry <vincent@nextcloud.com>2020-12-02 14:22:01 +0300
committerVincent Petry <vincent@nextcloud.com>2020-12-11 20:15:48 +0300
commit353206e1e695d531f2a51003ac93cfc3cd669bce (patch)
tree3b29ffeabce403a08033bf86517af956a278af22 /lib/Controller
parentf4d26223b3d22ecf2435c67adccf05629102be7f (diff)
Adjust approach for search results for listable rooms
Added "/listable-room" endpoint for listing listable rooms with a similar result format like the "/room" endpoint. Switched left sidebar to use Conversation components for displaying results. Signed-off-by: Vincent Petry <vincent@nextcloud.com>
Diffstat (limited to 'lib/Controller')
-rw-r--r--lib/Controller/RoomController.php71
1 files changed, 61 insertions, 10 deletions
diff --git a/lib/Controller/RoomController.php b/lib/Controller/RoomController.php
index c05c98bdd..047fd72f7 100644
--- a/lib/Controller/RoomController.php
+++ b/lib/Controller/RoomController.php
@@ -68,6 +68,7 @@ use OCP\UserStatus\IUserStatus;
class RoomController extends AEnvironmentAwareController {
public const EVENT_BEFORE_ROOMS_GET = self::class . '::preGetRooms';
+ public const EVENT_BEFORE_LISTED_ROOMS_GET = self::class . '::preGetListedRooms';
/** @var string|null */
protected $userId;
@@ -220,6 +221,37 @@ class RoomController extends AEnvironmentAwareController {
}
/**
+ * Search listed rooms
+ *
+ * @NoAdminRequired
+ *
+ * @param string $searchTerm search term
+ * @return DataResponse
+ */
+ public function getListedRooms(string $searchTerm = ''): DataResponse {
+ $event = new UserEvent($this->userId);
+ $this->dispatcher->dispatch(self::EVENT_BEFORE_LISTED_ROOMS_GET, $event);
+
+ $rooms = $this->manager->getListedRoomsForUser($this->userId, $searchTerm);
+
+ $return = [];
+ foreach ($rooms as $room) {
+ try {
+ $roomData = $this->formatRoom($room, null);
+ // since formatRoom will break early due to having no participant,
+ // we populate the remaining base attributes here
+ $return[] = $this->populateBaseRoomData($roomData, $room, $this->userId);
+ // TODO: should we populate more ?
+ } catch (RoomNotFoundException $e) {
+ } catch (\RuntimeException $e) {
+ }
+ }
+
+ return new DataResponse($return, Http::STATUS_OK);
+ }
+
+
+ /**
* @PublicPage
*
* @param string $token
@@ -599,20 +631,12 @@ class RoomController extends AEnvironmentAwareController {
$attendee = $currentParticipant->getAttendee();
$userId = $attendee->getActorType() === Attendee::ACTOR_USERS ? $attendee->getActorId() : '';
+ $roomData = $this->populateBaseRoomData($roomData, $room, $userId);
+
$roomData = array_merge($roomData, [
- 'name' => $room->getName(),
- 'displayName' => $room->getDisplayName($userId),
- 'objectType' => $room->getObjectType(),
- 'objectId' => $room->getObjectId(),
'participantType' => $attendee->getParticipantType(),
- 'readOnly' => $room->getReadOnly(),
- 'listable' => $room->getListable(),
- 'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
- 'lastActivity' => $lastActivity,
'isFavorite' => $attendee->isFavorite(),
'notificationLevel' => $attendee->getNotificationLevel(),
- 'lobbyState' => $room->getLobbyState(),
- 'lobbyTimer' => $lobbyTimer,
]);
if ($this->getAPIVersion() >= 3) {
if ($this->talkConfig->isSIPConfigured()) {
@@ -732,6 +756,33 @@ class RoomController extends AEnvironmentAwareController {
return $roomData;
}
+ protected function populateBaseRoomData(array $roomData, Room $room, $userId) {
+ $lastActivity = $room->getLastActivity();
+ if ($lastActivity instanceof \DateTimeInterface) {
+ $lastActivity = $lastActivity->getTimestamp();
+ } else {
+ $lastActivity = 0;
+ }
+
+ $lobbyTimer = $room->getLobbyTimer();
+ if ($lobbyTimer instanceof \DateTimeInterface) {
+ $lobbyTimer = $lobbyTimer->getTimestamp();
+ } else {
+ $lobbyTimer = 0;
+ }
+
+ return array_merge($roomData, [
+ 'name' => $room->getName(),
+ 'displayName' => $room->getDisplayName($userId),
+ 'objectType' => $room->getObjectType(),
+ 'objectId' => $room->getObjectId(),
+ 'readOnly' => $room->getReadOnly(),
+ 'listable' => $room->getListable(),
+ 'hasCall' => $room->getActiveSince() instanceof \DateTimeInterface,
+ 'lobbyState' => $room->getLobbyState(),
+ ]);
+ }
+
/**
* @param Room $room
* @param Participant $participant