1
0
mirror of https://github.com/BookStackApp/BookStack.git synced 2024-11-23 11:22:33 +01:00

fix: Actually check if we have correct data

This commit is contained in:
Marc Hagen 2023-09-18 20:04:59 +02:00
parent ea7592509f
commit ca98155373
No known key found for this signature in database

View File

@ -56,7 +56,7 @@ class UserAvatars
/**
* Destroy all user avatars uploaded to the given user.
*/
public function destroyAllForUser(User $user)
public function destroyAllForUser(User $user): void
{
$profileImages = Image::query()->where('type', '=', 'user')
->where('uploaded_to', '=', $user->id)
@ -70,7 +70,7 @@ class UserAvatars
/**
* Save an avatar image from an external service.
*
* @throws Exception
* @throws HttpFetchException
*/
protected function saveAvatarImage(User $user, int $size = 500): Image
{
@ -114,12 +114,14 @@ class UserAvatars
try {
$client = $this->http->buildClient(5);
$response = $client->sendRequest(new Request('GET', $url));
$imageData = (string) $response->getBody();
if ($response->getStatusCode() !== 200) {
throw new HttpFetchException(trans('errors.cannot_get_image_from_url', ['url' => $url]));
}
return (string) $response->getBody();
} catch (ClientExceptionInterface $exception) {
throw new HttpFetchException(trans('errors.cannot_get_image_from_url', ['url' => $url]), $exception->getCode(), $exception);
}
return $imageData;
}
/**