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 <blizzz@arthur-schiwon.de>
This commit is contained in:
Arthur Schiwon 2017-12-12 17:36:31 +01:00
parent 2943b54f98
commit 099a340bf5
No known key found for this signature in database
GPG Key ID: 7424F1874854DF23
2 changed files with 15 additions and 12 deletions

View File

@ -60,14 +60,3 @@ $commentsManager->registerEventHandler(function () {
$handler = $application->getContainer()->query(\OCA\Comments\EventHandler::class); $handler = $application->getContainer()->query(\OCA\Comments\EventHandler::class);
return $handler; return $handler;
}); });
$commentsManager->registerDisplayNameResolver('user', function($id) {
$manager = \OC::$server->getUserManager();
$user = $manager->get($id);
if(is_null($user)) {
$l = \OC::$server->getL10N('comments');
$displayName = $l->t('Unknown user');
} else {
$displayName = $user->getDisplayName();
}
return $displayName;
});

View File

@ -897,7 +897,21 @@ class Server extends ServerContainer implements IServerContainer {
$factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory'); $factoryClass = $config->getSystemValue('comments.managerFactory', '\OC\Comments\ManagerFactory');
/** @var \OCP\Comments\ICommentsManagerFactory $factory */ /** @var \OCP\Comments\ICommentsManagerFactory $factory */
$factory = new $factoryClass($this); $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); $this->registerAlias('CommentsManager', \OCP\Comments\ICommentsManager::class);