diff --git a/lib/Search/CurrentMessageSearch.php b/lib/Search/CurrentMessageSearch.php index 685a2a9f47d..126099aa553 100644 --- a/lib/Search/CurrentMessageSearch.php +++ b/lib/Search/CurrentMessageSearch.php @@ -27,6 +27,8 @@ use OCA\Talk\Exceptions\ParticipantNotFoundException; use OCA\Talk\Exceptions\RoomNotFoundException; use OCA\Talk\Exceptions\UnauthorizedException; +use OCA\Talk\Model\Attendee; +use OCA\Talk\Webinary; use OCP\IUser; use OCP\Search\ISearchQuery; use OCP\Search\SearchResult; @@ -87,6 +89,23 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { ); } + try { + $participant = $room->getParticipant($user->getUID(), false); + } catch (ParticipantNotFoundException $e) { + return SearchResult::complete( + $this->l->t('Messages'), + [] + ); + } + + if ($room->getLobbyState() !== Webinary::LOBBY_NONE && + !($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) { + return SearchResult::complete( + $this->l->t('Messages'), + [] + ); + } + $offset = (int) $query->getCursor(); $comments = $this->chatManager->searchForObjects( $query->getTerm(), diff --git a/lib/Search/MessageSearch.php b/lib/Search/MessageSearch.php index 93d05739919..6ac0dfc3fc1 100644 --- a/lib/Search/MessageSearch.php +++ b/lib/Search/MessageSearch.php @@ -31,6 +31,7 @@ use OCA\Talk\Manager as RoomManager; use OCA\Talk\Model\Attendee; use OCA\Talk\Room; +use OCA\Talk\Webinary; use OCP\Comments\IComment; use OCP\IL10N; use OCP\IURLGenerator; @@ -120,6 +121,13 @@ public function search(IUser $user, ISearchQuery $query): SearchResult { continue; } + if ($room->getLobbyState() !== Webinary::LOBBY_NONE) { + $participant = $room->getParticipant($user->getUID(), false); + if (!($participant->getPermissions() & Attendee::PERMISSIONS_LOBBY_IGNORE)) { + continue; + } + } + $roomMap[(string) $room->getId()] = $room; }