aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorCarl Schwan <carl@carlschwan.eu>2022-08-30 13:58:51 +0200
committerCarl Schwan <carl@carlschwan.eu>2022-09-09 13:37:51 +0200
commit76d01653309f1535bfe8d364a5aae50e83a348e3 (patch)
tree1e5b15504a1251b3810a478fc8cbca9dd69477e3 /core
parentf98ae2b5b0567f28a875106724c0475d6395f3c5 (diff)
downloadnextcloud-server-76d01653309f1535bfe8d364a5aae50e83a348e3.tar.gz
nextcloud-server-76d01653309f1535bfe8d364a5aae50e83a348e3.zip
Dark theme for guest avatar
And better caching policy Signed-off-by: Carl Schwan <carl@carlschwan.eu>
Diffstat (limited to 'core')
-rw-r--r--core/Controller/GuestAvatarController.php13
-rw-r--r--core/routes.php1
2 files changed, 12 insertions, 2 deletions
diff --git a/core/Controller/GuestAvatarController.php b/core/Controller/GuestAvatarController.php
index 9c0606f368f..09146ff3928 100644
--- a/core/Controller/GuestAvatarController.php
+++ b/core/Controller/GuestAvatarController.php
@@ -60,8 +60,9 @@ class GuestAvatarController extends Controller {
* @param string $size The desired avatar size, e.g. 64 for 64x64px
* @return FileDisplayResponse|Http\Response
*/
- public function getAvatar(string $guestName, string $size) {
+ public function getAvatar(string $guestName, string $size, ?bool $dark = false) {
$size = (int) $size;
+ $dark = $dark === null ? false : $dark;
if ($size <= 64) {
if ($size !== 64) {
@@ -94,7 +95,15 @@ class GuestAvatarController extends Controller {
}
// Cache for 30 minutes
- $resp->cacheFor(1800);
+ $resp->cacheFor(1800, false, true);
return $resp;
}
+
+ /**
+ * @PublicPage
+ * @NoCSRFRequired
+ */
+ public function getAvatarDark(string $guestName, string $size) {
+ return $this->getAvatar($guestName, $size, true);
+ }
}
diff --git a/core/routes.php b/core/routes.php
index ee5fbb34a4c..5e08213828d 100644
--- a/core/routes.php
+++ b/core/routes.php
@@ -51,6 +51,7 @@ $application->registerRoutes($this, [
['name' => 'avatar#postCroppedAvatar', 'url' => '/avatar/cropped', 'verb' => 'POST'],
['name' => 'avatar#getTmpAvatar', 'url' => '/avatar/tmp', 'verb' => 'GET'],
['name' => 'avatar#postAvatar', 'url' => '/avatar/', 'verb' => 'POST'],
+ ['name' => 'GuestAvatar#getAvatarDark', 'url' => '/avatar/guest/{guestName}/{size}/dark', 'verb' => 'GET'],
['name' => 'GuestAvatar#getAvatar', 'url' => '/avatar/guest/{guestName}/{size}', 'verb' => 'GET'],
['name' => 'CSRFToken#index', 'url' => '/csrftoken', 'verb' => 'GET'],
['name' => 'login#tryLogin', 'url' => '/login', 'verb' => 'POST'],