diff options
author | Vitor Mattos <vitor@php.rio> | 2021-09-28 18:02:22 +0300 |
---|---|---|
committer | Vitor Mattos <vitor@php.rio> | 2021-09-29 14:42:35 +0300 |
commit | e89466930fff3c543a9b7630750ab8e99a5b5432 (patch) | |
tree | ccea711cfafea6b10c4e41b88630ec76e933872f /lib/Chat/ChatManager.php | |
parent | b9be9ae1b1dba86f7c7dbec927438800cd3636f0 (diff) |
Moved code to specialist method and add fallback to all
Signed-off-by: Vitor Mattos <vitor@php.rio>
Update lib/Chat/ChatManager.php
Co-authored-by: Joas Schilling <213943+nickvergessen@users.noreply.github.com>
Diffstat (limited to 'lib/Chat/ChatManager.php')
-rw-r--r-- | lib/Chat/ChatManager.php | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/Chat/ChatManager.php b/lib/Chat/ChatManager.php index 7cca61fc5..36e8cd4d0 100644 --- a/lib/Chat/ChatManager.php +++ b/lib/Chat/ChatManager.php @@ -531,4 +531,37 @@ class ChatManager { public function searchForObjects(string $search, array $objectIds, string $verb = '', int $offset = 0, int $limit = 50): array { return $this->commentsManager->searchForObjects($search, 'chat', $objectIds, $verb, $offset, $limit); } + + public function addConversationNotify(array $results, string $search, Room $room, Participant $participant): array { + if ($room->getType() === Room::TYPE_ONE_TO_ONE) { + return $results; + } + $attendee = $participant->getAttendee(); + if ($attendee->getActorType() === Attendee::ACTOR_USERS) { + $roomDisplayName = $room->getDisplayName($attendee->getActorId()); + } else { + $roomDisplayName = $room->getDisplayName(''); + } + if ($search === '' || $this->searchIsPartOfConversationNameOrAtAll($search, $roomDisplayName)) { + array_unshift($results, [ + 'id' => 'all', + 'label' => $roomDisplayName, + 'source' => 'calls', + ]); + } + return $results; + } + + private function searchIsPartOfConversationNameOrAtAll(string $search, string $roomDisplayName): bool { + if (stripos($roomDisplayName, $search) === 0) { + return true; + } + if (strpos('all', $search) === 0) { + return true; + } + if (strpos('here', $search) === 0) { + return true; + } + return false; + } } |