summaryrefslogtreecommitdiffstats
path: root/apps/comments/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2016-11-16 12:15:34 +0100
committerJoas Schilling <coding@schilljs.com>2016-11-16 12:20:04 +0100
commitcf205fcaa5f3872e438fd4e65aeb39f7de57006a (patch)
tree15ab65c8bd041d63e32607b9a491b74e78085c5e /apps/comments/lib
parent8105ba99297222b7db97b556a55f306c3f7cabc0 (diff)
downloadnextcloud-server-cf205fcaa5f3872e438fd4e65aeb39f7de57006a.tar.gz
nextcloud-server-cf205fcaa5f3872e438fd4e65aeb39f7de57006a.zip
Use the display name for users
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/comments/lib')
-rw-r--r--apps/comments/lib/Activity/Provider.php45
1 files changed, 41 insertions, 4 deletions
diff --git a/apps/comments/lib/Activity/Provider.php b/apps/comments/lib/Activity/Provider.php
index 4999d418785..9035087965c 100644
--- a/apps/comments/lib/Activity/Provider.php
+++ b/apps/comments/lib/Activity/Provider.php
@@ -28,6 +28,8 @@ use OCP\Comments\ICommentsManager;
use OCP\Comments\NotFoundException;
use OCP\IL10N;
use OCP\IURLGenerator;
+use OCP\IUser;
+use OCP\IUserManager;
class Provider implements IProvider {
@@ -40,19 +42,27 @@ class Provider implements IProvider {
/** @var ICommentsManager */
protected $commentsManager;
+ /** @var IUserManager */
+ protected $userManager;
+
/** @var IManager */
protected $activityManager;
+ /** @var string[] */
+ protected $displayNames = [];
+
/**
* @param IL10N $l
* @param IURLGenerator $url
* @param ICommentsManager $commentsManager
+ * @param IUserManager $userManager
* @param IManager $activityManager
*/
- public function __construct(IL10N $l, IURLGenerator $url, ICommentsManager $commentsManager, IManager $activityManager) {
+ public function __construct(IL10N $l, IURLGenerator $url, ICommentsManager $commentsManager, IUserManager $userManager, IManager $activityManager) {
$this->l = $l;
$this->url = $url;
$this->commentsManager = $commentsManager;
+ $this->userManager = $userManager;
$this->activityManager = $activityManager;
}
@@ -90,7 +100,6 @@ class Provider implements IProvider {
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
- * @since 11.0.0
*/
protected function parseShortVersion(IEvent $event) {
$subjectParameters = $event->getSubjectParameters();
@@ -117,7 +126,6 @@ class Provider implements IProvider {
* @param IEvent $event
* @return IEvent
* @throws \InvalidArgumentException
- * @since 11.0.0
*/
protected function parseLongVersion(IEvent $event) {
$subjectParameters = $event->getSubjectParameters();
@@ -148,6 +156,9 @@ class Provider implements IProvider {
return $event;
}
+ /**
+ * @param IEvent $event
+ */
protected function parseMessage(IEvent $event) {
$messageParameters = $event->getMessageParameters();
try {
@@ -178,6 +189,11 @@ class Provider implements IProvider {
}
}
+ /**
+ * @param int $id
+ * @param string $path
+ * @return array
+ */
protected function generateFileParameter($id, $path) {
return [
'type' => 'file',
@@ -188,11 +204,32 @@ class Provider implements IProvider {
];
}
+ /**
+ * @param string $uid
+ * @return array
+ */
protected function generateUserParameter($uid) {
+ if (!isset($this->displayNames[$uid])) {
+ $this->displayNames[$uid] = $this->getDisplayName($uid);
+ }
+
return [
'type' => 'user',
'id' => $uid,
- 'name' => $uid,// FIXME Use display name
+ 'name' => $this->displayNames[$uid],
];
}
+
+ /**
+ * @param string $uid
+ * @return string
+ */
+ protected function getDisplayName($uid) {
+ $user = $this->userManager->get($uid);
+ if ($user instanceof IUser) {
+ return $user->getDisplayName();
+ } else {
+ return $uid;
+ }
+ }
}