kopia lustrzana https://github.com/nextcloud/social
retrieve displayName on cache refresh
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>pull/144/head
rodzic
f76aa3e67e
commit
9f9e6a75ef
|
|
@ -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,12 +274,32 @@ class ActorService {
|
|||
];
|
||||
$actor->addDetailArray('count', $count);
|
||||
|
||||
$this->updateCacheLocalActorName($actor);
|
||||
|
||||
$this->personService->cacheLocalActor($actor, $refresh);
|
||||
} catch (ActorDoesNotExistException $e) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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
|
||||
*/
|
||||
|
|
|
|||
Ładowanie…
Reference in New Issue