aboutsummaryrefslogtreecommitdiffstats
path: root/core/Controller
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-06-06 18:48:14 +0200
committerJohn Molakvoæ <skjnldsv@users.noreply.github.com>2024-06-12 13:23:39 +0200
commit339fdfb6b59a33e2f789be9f15069ffd09442b70 (patch)
treead0226d95164b3f56ee58ae2dd15f8fc828d37ac /core/Controller
parentd991eaed92de9ac7380d8e1978c298fb91673b98 (diff)
downloadnextcloud-server-339fdfb6b59a33e2f789be9f15069ffd09442b70.tar.gz
nextcloud-server-339fdfb6b59a33e2f789be9f15069ffd09442b70.zip
fix(core): allow guest avatar fallback
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'core/Controller')
-rw-r--r--core/Controller/AvatarController.php10
1 files changed, 10 insertions, 0 deletions
diff --git a/core/Controller/AvatarController.php b/core/Controller/AvatarController.php
index 32858b52612..e2aba26b8b7 100644
--- a/core/Controller/AvatarController.php
+++ b/core/Controller/AvatarController.php
@@ -37,12 +37,14 @@ use OCP\AppFramework\Http;
use OCP\AppFramework\Http\DataDisplayResponse;
use OCP\AppFramework\Http\FileDisplayResponse;
use OCP\AppFramework\Http\JSONResponse;
+use OCP\AppFramework\Http\RedirectResponse;
use OCP\Files\File;
use OCP\Files\IRootFolder;
use OCP\IAvatarManager;
use OCP\ICache;
use OCP\IL10N;
use OCP\IRequest;
+use OCP\IURLGenerator;
use OCP\IUserManager;
use Psr\Log\LoggerInterface;
@@ -63,6 +65,8 @@ class AvatarController extends Controller {
protected LoggerInterface $logger,
protected ?string $userId,
protected TimeFactory $timeFactory,
+ protected IURLGenerator $urlGenerator,
+ protected GuestAvatarController $guestAvatarController,
) {
parent::__construct($appName, $request);
}
@@ -104,6 +108,9 @@ class AvatarController extends Controller {
['Content-Type' => $avatarFile->getMimeType(), 'X-NC-IsCustomAvatar' => (int)$avatar->isCustomAvatar()]
);
} catch (\Exception $e) {
+ if ($guestFallback) {
+ return $this->guestAvatarController->getAvatarDark($userId, (string)$size);
+ }
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}
@@ -150,6 +157,9 @@ class AvatarController extends Controller {
['Content-Type' => $avatarFile->getMimeType(), 'X-NC-IsCustomAvatar' => (int)$avatar->isCustomAvatar()]
);
} catch (\Exception $e) {
+ if ($guestFallback) {
+ return $this->guestAvatarController->getAvatar($userId, (string)$size);
+ }
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}