diff options
author | Maxence Lange <maxence@artificial-owl.com> | 2018-12-05 21:56:52 -0100 |
---|---|---|
committer | Maxence Lange <maxence@artificial-owl.com> | 2018-12-05 21:56:52 -0100 |
commit | 9f9e6a75ef51132e4b5a1b5113e6b8448cde0487 (patch) | |
tree | 0466872fe62c1ca57f9aa2da224b4c21c1b91bbd /lib | |
parent | f76aa3e67eed4de750ac5e7fbceb4227702a6dbb (diff) |
retrieve displayName on cache refresh
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Service/ActorService.php | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/Service/ActorService.php b/lib/Service/ActorService.php index e54c3ddf..9bac2f22 100644 --- a/lib/Service/ActorService.php +++ b/lib/Service/ActorService.php @@ -45,7 +45,7 @@ use OCA\Social\Model\ActivityPub\Person; use OCA\Social\Service\ActivityPub\DocumentService; use OCA\Social\Service\ActivityPub\PersonService; use OCP\Accounts\IAccountManager; -use OCP\IURLGenerator; +use OCP\Accounts\PropertyDoesNotExistException; use OCP\IUserManager; @@ -60,6 +60,9 @@ class ActorService { use TArrayTools; + /** @var IUserManager */ + private $userManager; + /** @var IAccountManager */ private $accountManager; @@ -88,6 +91,7 @@ class ActorService { /** * ActorService constructor. * + * @param IUserManager $userManager * @param IAccountManager $accountManager * @param ActorsRequest $actorsRequest * @param FollowsRequest $followsRequest @@ -98,10 +102,11 @@ class ActorService { * @param MiscService $miscService */ public function __construct( - IAccountManager $accountManager, ActorsRequest $actorsRequest, + IUserManager $userManager, IAccountManager $accountManager, ActorsRequest $actorsRequest, FollowsRequest $followsRequest, NotesRequest $notesRequest, PersonService $personService, DocumentService $documentService, ConfigService $configService, MiscService $miscService ) { + $this->userManager = $userManager; $this->accountManager = $accountManager; $this->actorsRequest = $actorsRequest; $this->followsRequest = $followsRequest; @@ -269,6 +274,8 @@ class ActorService { ]; $actor->addDetailArray('count', $count); + $this->updateCacheLocalActorName($actor); + $this->personService->cacheLocalActor($actor, $refresh); } catch (ActorDoesNotExistException $e) { } @@ -276,6 +283,24 @@ class ActorService { /** + * @param Person $actor + */ + private function updateCacheLocalActorName(Person &$actor) { + $user = $this->userManager->get($actor->getUserId()); + $account = $this->accountManager->getAccount($user); + + try { + $displayNameProperty = $account->getProperty(IAccountManager::PROPERTY_DISPLAYNAME); + if ($displayNameProperty->getScope() === IAccountManager::VISIBILITY_PUBLIC) { + $actor->setName($displayNameProperty->getValue()); + } + } catch (PropertyDoesNotExistException $e) { + } + + } + + + /** * @param $username */ private function checkActorUsername($username) { |