userSession->getUser()->getUID(); $result = ['wide' => [], 'exact' => []]; $rooms = $this->manager->getRoomsForUser($userId); foreach ($rooms as $room) { if ($room->getReadOnly() === Room::READ_ONLY) { // Can not add new shares to read-only rooms continue; } if ($room->isFederatedConversation()) { continue; } $participant = $this->participantService->getParticipant($room, $userId, false); if (!($participant->getPermissions() & Attendee::PERMISSIONS_CHAT)) { // No chat permissions is like read-only continue; } if (mb_stripos($room->getDisplayName($userId), $search) !== false) { $item = $this->roomToSearchResultItem($room, $userId); if (mb_strtolower($item['label']) === mb_strtolower($search)) { $result['exact'][] = $item; } else { $result['wide'][] = $item; } } } $type = new SearchResultType('rooms'); $searchResult->addResultSet($type, $result['wide'], $result['exact']); return false; } private function roomToSearchResultItem(Room $room, string $userId): array { return [ 'label' => $room->getDisplayName($userId), 'value' => [ 'shareType' => IShare::TYPE_ROOM, 'shareWith' => $room->getToken() ] ]; } }