diff options
author | Joas Schilling <coding@schilljs.com> | 2020-01-28 12:27:47 +0100 |
---|---|---|
committer | Roeland Jago Douma <roeland@famdouma.nl> | 2020-03-10 19:36:56 +0100 |
commit | bbef026aa075f4432210fcc8f089283f56f2bf72 (patch) | |
tree | a40fe948a9f06d8d74bdd1bc827b5e9a09b977a0 /apps/files/lib | |
parent | 812f16880b2cf5968a351e2f9928299458ce7b3d (diff) | |
download | nextcloud-server-bbef026aa075f4432210fcc8f089283f56f2bf72.tar.gz nextcloud-server-bbef026aa075f4432210fcc8f089283f56f2bf72.zip |
Use contacts name on federated activities
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'apps/files/lib')
-rw-r--r-- | apps/files/lib/Activity/Provider.php | 46 |
1 files changed, 35 insertions, 11 deletions
diff --git a/apps/files/lib/Activity/Provider.php b/apps/files/lib/Activity/Provider.php index 07bc471281c..56d9f750fdf 100644 --- a/apps/files/lib/Activity/Provider.php +++ b/apps/files/lib/Activity/Provider.php @@ -28,6 +28,7 @@ use OCP\Activity\IEvent; use OCP\Activity\IEventMerger; use OCP\Activity\IManager; use OCP\Activity\IProvider; +use OCP\Contacts\IManager as IContactsManager; use OCP\Files\Folder; use OCP\Files\InvalidPathException; use OCP\Files\IRootFolder; @@ -64,25 +65,27 @@ class Provider implements IProvider { /** @var IEventMerger */ protected $eventMerger; + /** @var IContactsManager */ + protected $contactsManager; + /** @var string[] cached displayNames - key is the UID and value the displayname */ protected $displayNames = []; protected $fileIsEncrypted = false; - /** - * @param IFactory $languageFactory - * @param IURLGenerator $url - * @param IManager $activityManager - * @param IUserManager $userManager - * @param IRootFolder $rootFolder - * @param IEventMerger $eventMerger - */ - public function __construct(IFactory $languageFactory, IURLGenerator $url, IManager $activityManager, IUserManager $userManager, IRootFolder $rootFolder, IEventMerger $eventMerger) { + public function __construct(IFactory $languageFactory, + IURLGenerator $url, + IManager $activityManager, + IUserManager $userManager, + IRootFolder $rootFolder, + IContactsManager $contactsManager, + IEventMerger $eventMerger) { $this->languageFactory = $languageFactory; $this->url = $url; $this->activityManager = $activityManager; $this->userManager = $userManager; $this->rootFolder = $rootFolder; + $this->contactsManager = $contactsManager; $this->eventMerger = $eventMerger; } @@ -499,8 +502,29 @@ class Provider implements IProvider { $user = $this->userManager->get($uid); if ($user instanceof IUser) { return $user->getDisplayName(); - } else { - return $uid; } + + $addressBookContacts = $this->contactsManager->search($uid, ['CLOUD']); + foreach ($addressBookContacts as $contact) { + if (isset($contact['isLocalSystemBook'])) { + continue; + } + + if (isset($contact['CLOUD'])) { + $cloudIds = $contact['CLOUD']; + if (is_string($cloudIds)) { + $cloudIds = [$cloudIds]; + } + + $lowerSearch = strtolower($uid); + foreach ($cloudIds as $cloudId) { + if (strtolower($cloudId) === $lowerSearch) { + return $contact['FN'] . " ($cloudId)"; + } + } + } + } + + return $uid; } } |