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:
parent
2943b54f98
commit
099a340bf5
|
@ -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;
|
|
||||||
});
|
|
||||||
|
|
|
@ -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);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue