summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-18 09:58:42 +0200
committerJoas Schilling <coding@schilljs.com>2022-08-19 12:06:21 +0200
commite32de5d5f9ea86cc66dbd472b0aee09fc81f7113 (patch)
tree961e7d37ea0577753442382fe5d7ad36fca64954 /lib
parent1c29d7714f899b44507306dd4b3b05e0c4e02dfc (diff)
Use user displayname cache in autocomplete search
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Chat/AutoComplete/SearchPlugin.php19
1 files changed, 7 insertions, 12 deletions
diff --git a/lib/Chat/AutoComplete/SearchPlugin.php b/lib/Chat/AutoComplete/SearchPlugin.php
index 9cabe3e85..cfb93baff 100644
--- a/lib/Chat/AutoComplete/SearchPlugin.php
+++ b/lib/Chat/AutoComplete/SearchPlugin.php
@@ -139,18 +139,18 @@ class SearchPlugin implements ISearchPlugin {
continue;
}
- $user = $this->userManager->get($userId);
- if (!$user instanceof IUser) {
+ $userDisplayName = $this->userManager->getDisplayName($userId);
+ if ($userDisplayName === null) {
continue;
}
- if (strtolower($user->getDisplayName()) === $search) {
- $exactMatches[] = $this->createResult('user', $user->getUID(), $user->getDisplayName());
+ if (strtolower($userDisplayName) === $search) {
+ $exactMatches[] = $this->createResult('user', $userId, $userDisplayName);
continue;
}
- if (stripos($user->getDisplayName(), $search) !== false) {
- $matches[] = $this->createResult('user', $user->getUID(), $user->getDisplayName());
+ if (stripos($userDisplayName, $search) !== false) {
+ $matches[] = $this->createResult('user', $userId, $userDisplayName);
continue;
}
}
@@ -207,12 +207,7 @@ class SearchPlugin implements ISearchPlugin {
protected function createResult(string $type, string $uid, string $name): array {
if ($type === 'user' && $name === '') {
- $user = $this->userManager->get($uid);
- if ($user instanceof IUser) {
- $name = $user->getDisplayName();
- } else {
- $name = $uid;
- }
+ $name = $this->userManager->getDisplayName($uid) ?? $uid;
}
return [