summaryrefslogtreecommitdiffstats
path: root/lib/Search
diff options
context:
space:
mode:
authorVitor Mattos <vitor@php.rio>2022-11-11 20:17:20 -0300
committerJoas Schilling <coding@schilljs.com>2022-12-07 15:00:29 +0100
commit9be3867958bc1c16df19d4975445f47d1e52b83b (patch)
treeabef2f431dd94076ced226b61148a81dad2c0869 /lib/Search
parentfbe11e45065b49e3a80e01d56159bf2ffe704172 (diff)
Return room avatar in global search
Signed-off-by: Vitor Mattos <vitor@php.rio>
Diffstat (limited to 'lib/Search')
-rw-r--r--lib/Search/ConversationSearch.php28
1 files changed, 15 insertions, 13 deletions
diff --git a/lib/Search/ConversationSearch.php b/lib/Search/ConversationSearch.php
index 9255bc282..3d04bdc67 100644
--- a/lib/Search/ConversationSearch.php
+++ b/lib/Search/ConversationSearch.php
@@ -26,6 +26,7 @@ namespace OCA\Talk\Search;
use OCA\Talk\AppInfo\Application;
use OCA\Talk\Manager;
use OCA\Talk\Room;
+use OCA\Talk\Service\AvatarService;
use OCP\IL10N;
use OCP\IURLGenerator;
use OCP\IUser;
@@ -35,15 +36,18 @@ use OCP\Search\SearchResult;
use OCP\Search\SearchResultEntry;
class ConversationSearch implements IProvider {
+ protected AvatarService $avatarService;
protected Manager $manager;
protected IURLGenerator $url;
protected IL10N $l;
public function __construct(
+ AvatarService $avatarService,
Manager $manager,
IURLGenerator $url,
IL10N $l
) {
+ $this->avatarService = $avatarService;
$this->manager = $manager;
$this->url = $url;
$this->l = $l;
@@ -113,20 +117,18 @@ class ConversationSearch implements IProvider {
}
}
- $icon = '';
+ if ($this->avatarService->roomHasAvatar($room)) {
+ $icon = $this->url->linkToRouteAbsolute('ocs.spreed.Avatar.getAvatar', [
+ 'token' => $room->getToken(),
+ 'apiVersion' => 'v1',
+ 'v' => $this->avatarService->getAvatarVersion($room, $user->getUID()),
+ ]);
+ } else {
+ $icon = '';
+ }
$iconClass = '';
- if ($room->getType() === Room::TYPE_ONE_TO_ONE) {
- $users = json_decode($room->getName(), true);
- foreach ($users as $participantId) {
- if ($participantId !== $user->getUID()) {
- $icon = $this->url->linkToRouteAbsolute('core.avatar.getAvatar', [
- 'userId' => $participantId,
- 'size' => 512,
- ]);
- }
- }
- } elseif ($room->getObjectType() === 'file') {
- $iconClass = 'conversation-icon icon-file-white';
+ if ($room->getObjectType() === 'file') {
+ $iconClass = 'conversation-icon icon-text-white';
} elseif ($room->getObjectType() === 'share:password') {
$iconClass = 'conversation-icon icon-password-white';
} elseif ($room->getObjectType() === 'emails') {