setViewerId() to specify a PoV

Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
pull/82/head
Maxence Lange 2018-11-30 09:57:35 -01:00
rodzic 378a43d23e
commit 7d8e2b1065
1 zmienionych plików z 19 dodań i 14 usunięć

Wyświetl plik

@ -76,6 +76,10 @@ class PersonService implements ICoreService {
private $miscService;
/** @var string */
private $viewerId = '';
/**
* UndoService constructor.
*
@ -97,6 +101,18 @@ class PersonService implements ICoreService {
}
/**
* @param string $viewerId
*/
public function setViewerId(string $viewerId) {
$this->viewerId = $viewerId;
}
public function getViewerId(): string {
return $this->viewerId;
}
/**
* @param Person $actor
* @param bool $refresh
@ -169,7 +185,7 @@ class PersonService implements ICoreService {
public function getFromAccount(string $account, bool $retrieve = true): Person {
try {
$actor = $this->cacheActorsRequest->getFromAccount($account);
$actor = $this->cacheActorsRequest->getFromAccount($account, $this->getViewerId());
} catch (CacheActorDoesNotExistException $e) {
if (!$retrieve) {
throw new CacheActorDoesNotExistException();
@ -219,18 +235,7 @@ class PersonService implements ICoreService {
}
$actor->setSource(json_encode($object, JSON_UNESCAPED_SLASHES));
// $actor->setPreferredUsername($this->get('preferredUsername', $object, ''));
// $actor->setPublicKey($this->get('publicKey.publicKeyPem', $object));
// $actor->setSharedInbox($this->get('endpoints.sharedInbox', $object));
// $actor->setAccount($actor->getPreferredUsername() . '@' . $this->get('_host', $object));
//
// $icon = new Image($actor);
// $icon->setUrlCloud($this->configService->getCloudAddress());
// $icon->import($this->getArray('icon', $object, []));
// if ($icon->getType() === Image::TYPE) {
// $actor->setIcon($icon);
// }
//
return $actor;
}
@ -240,7 +245,7 @@ class PersonService implements ICoreService {
* @return Person[]
*/
public function searchCachedAccounts(string $search): array {
return $this->cacheActorsRequest->searchAccounts($search);
return $this->cacheActorsRequest->searchAccounts($search, $this->getViewerId());
}