Add proper NotFoundResponse if no avatar is available

Signed-off-by: Julius Härtl <jus@bitgrid.net>
pull/72/head
Julius Härtl 2018-11-29 14:24:00 +01:00
rodzic 53b5cc29e7
commit f92290713a
Nie znaleziono w bazie danych klucza dla tego podpisu
ID klucza GPG: 4C614C6ED2CDE6DF
1 zmienionych plików z 7 dodań i 5 usunięć

Wyświetl plik

@ -47,6 +47,7 @@ use OCA\Social\Service\PostService;
use OCP\AppFramework\Controller;
use OCP\AppFramework\Http\DataResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\NotFoundResponse;
use OCP\AppFramework\Http\Response;
use OCP\IRequest;
@ -415,11 +416,12 @@ class LocalController extends Controller {
public function actorAvatar(string $id): Response {
try {
$actor = $this->personService->getFromId($id);
$avatar = $actor->getIcon();
$document = $this->documentService->getFromCache($avatar->getId());
return new FileDisplayResponse($document);
if ($actor->gotIcon()) {
$avatar = $actor->getIcon();
$document = $this->documentService->getFromCache($avatar->getId());
return new FileDisplayResponse($document);
}
return new NotFoundResponse();
} catch (Exception $e) {
return $this->fail($e);
}