Add unified avatar endpoint to quickly fetch avatars

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/72/head
Julius Härtl 2018-11-28 22:40:08 +01:00
rodzic 2d06e10d80
commit 2ec04d611e
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4C614C6ED2CDE6DF
2 zmienionych plików z 21 dodań i 0 usunięć

Wyświetl plik

@ -76,6 +76,7 @@ return [
['name' => 'Local#accountUnfollow', 'url' => '/api/v1/account/follow', 'verb' => 'DELETE'],
['name' => 'Local#accountInfo', 'url' => '/api/v1/account/info', 'verb' => 'GET'],
['name' => 'Local#actorInfo', 'url' => '/api/v1/actor/info', 'verb' => 'GET'],
['name' => 'Local#actorAvatar', 'url' => '/api/v1/actor/avatar', 'verb' => 'GET'],
['name' => 'Local#documentsCache', 'url' => '/api/v1/documents/cache', 'verb' => 'POST'],
['name' => 'Queue#asyncWithToken', 'url' => CurlService::ASYNC_TOKEN, 'verb' => 'POST'],

Wyświetl plik

@ -403,6 +403,26 @@ class LocalController extends Controller {
}
}
/**
* @NoCSRFRequired
* @NoAdminRequired
* @NoSubAdminRequired
* @param string $id
* @return DataResponse
*/
public function actorAvatar(string $id): DataResponse {
try {
$actor = $this->personService->getFromId($id);
$avatar = $actor->getIcon();
$this->documentService->getFromCache($avatar->getId());
return $this->success(['actor' => $actor]);
} catch (Exception $e) {
return $this->fail($e);
}
}
/**
* // TODO: Delete the NoCSRF check