summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <coding@schilljs.com>2024-03-18 12:45:26 +0100
committerJoas Schilling <coding@schilljs.com>2024-03-18 12:45:26 +0100
commite0c23ee9720ce86d770442127fc7e1ab69809df3 (patch)
treec9c2f04adfea0a084370139d559e03bbfd9f105d /lib
parentdd0ce1a7679a8f5e0c5f0defa92c41250d9b5fec (diff)
fix(avatars): Reduce cache time in fallback cases (remote was offline)
Signed-off-by: Joas Schilling <coding@schilljs.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/Controller/AvatarController.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/Controller/AvatarController.php b/lib/Controller/AvatarController.php
index 8e98a9a1d..1d257ba80 100644
--- a/lib/Controller/AvatarController.php
+++ b/lib/Controller/AvatarController.php
@@ -147,6 +147,8 @@ class AvatarController extends AEnvironmentAwareController {
#[AllowWithoutParticipantWhenPendingInvitation]
#[RequireParticipantOrLoggedInAndListedConversation]
public function getAvatar(bool $darkTheme = false): FileDisplayResponse {
+ // Cache for 1 day
+ $cacheDuration = 60 * 60 * 24;
if ($this->room->getRemoteServer() !== '') {
/** @var \OCA\Talk\Federation\Proxy\TalkV1\Controller\AvatarController $proxy */
$proxy = \OCP\Server::get(\OCA\Talk\Federation\Proxy\TalkV1\Controller\AvatarController::class);
@@ -154,13 +156,14 @@ class AvatarController extends AEnvironmentAwareController {
return $proxy->getAvatar($this->room, $this->participant, $this->invitation, $darkTheme);
} catch (CannotReachRemoteException) {
// Falling back to a local "globe" avatar for indicating the federation
+ // Cache for 15 minutes only
+ $cacheDuration = 15 * 60;
}
}
$file = $this->avatarService->getAvatar($this->getRoom(), $this->userSession->getUser(), $darkTheme);
$response = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => $file->getMimeType()]);
- // Cache for 1 day
- $response->cacheFor(60 * 60 * 24, false, true);
+ $response->cacheFor($cacheDuration, false, true);
return $response;
}
@@ -277,7 +280,7 @@ class AvatarController extends AEnvironmentAwareController {
Http::STATUS_OK,
['Content-Type' => $file->getMimeType()],
);
- $response->cacheFor(60 * 60 * 24, false, true);
+ $response->cacheFor(60 * 15, false, true);
return $response;
}