From 099a340bf5f66e6c188e8896646802b998ba7063 Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Tue, 12 Dec 2017 17:36:31 +0100 Subject: The user displayNameResolver is specific to users, not the comments app Other apps like spreed rely on it, and only can resolver per type can be registered anyhow. Signed-off-by: Arthur Schiwon --- lib/private/Server.php | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'lib/private/Server.php') diff --git a/lib/private/Server.php b/lib/private/Server.php index 8a5fb0fa96c..6898e93e3bb 100644 --- a/lib/private/Server.php +++ b/lib/private/Server.php @@ -897,7 +897,21 @@ class Server extends ServerContainer implements IServerContainer { $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); /** @var \OCP\Comments\ICommentsManagerFactory $factory */ $factory = new $factoryClass($this); - return $factory->getManager(); + $manager = $factory->getManager(); + + $manager->registerDisplayNameResolver('user', function($id) use ($c) { + $manager = $c->getUserManager(); + $user = $manager->get($id); + if(is_null($user)) { + $l = $c->getL10N('core'); + $displayName = $l->t('Unknown user'); + } else { + $displayName = $user->getDisplayName(); + } + return $displayName; + }); + + return $manager; }); $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class); -- cgit v1.2.3