Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/server.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2022-08-19 01:09:46 +0300
committerJoas Schilling <coding@schilljs.com>2022-08-19 01:09:46 +0300
commite60820c5cacea5f3f716a746dfc4a45b2080e610 (patch)
treeaa92f0b2ea251ddeefe36f4c98488c6a9f0d1426
parentcab0f1327e28104ef61e8767f963d20cf38544af (diff)
Use user displayname cache for comment mentionsperf/noid/user-displayname-cache-for-comment-mentions
Signed-off-by: Joas Schilling <coding@schilljs.com>
-rw-r--r--apps/comments/lib/Notification/Notifier.php4
-rw-r--r--lib/private/Server.php12
2 files changed, 7 insertions, 9 deletions
diff --git a/apps/comments/lib/Notification/Notifier.php b/apps/comments/lib/Notification/Notifier.php
index 7c6a40133ee..b41962e0ac0 100644
--- a/apps/comments/lib/Notification/Notifier.php
+++ b/apps/comments/lib/Notification/Notifier.php
@@ -171,8 +171,8 @@ class Notifier implements INotifier {
$mentions = $comment->getMentions();
foreach ($mentions as $mention) {
if ($mention['type'] === 'user') {
- $user = $this->userManager->get($mention['id']);
- if (!$user instanceof IUser) {
+ $userDisplayName = $this->userManager->getDisplayName($mention['id']);
+ if ($userDisplayName === null) {
continue;
}
}
diff --git a/lib/private/Server.php b/lib/private/Server.php
index 7223c3b8ae3..8bbc9668542 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1186,14 +1186,12 @@ class Server extends ServerContainer implements IServerContainer {
$manager->registerDisplayNameResolver('user', function ($id) use ($c) {
$manager = $c->get(IUserManager::class);
- $user = $manager->get($id);
- if (is_null($user)) {
- $l = $c->getL10N('core');
- $displayName = $l->t('Unknown user');
- } else {
- $displayName = $user->getDisplayName();
+ $userDisplayName = $manager->getDisplayName($id);
+ if ($userDisplayName === null) {
+ $l = $c->get(IFactory::class)->get('core');
+ return $l->t('Unknown user');
}
- return $displayName;
+ return $userDisplayName;
});
return $manager;