Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions lib/Controller/AvatarController.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,20 +147,23 @@ public function emojiAvatar(string $emoji, ?string $color): DataResponse {
#[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);
try {
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;
}

Expand Down Expand Up @@ -277,7 +280,7 @@ protected function getPlaceholderResponse(bool $darkTheme): FileDisplayResponse
Http::STATUS_OK,
['Content-Type' => $file->getMimeType()],
);
$response->cacheFor(60 * 60 * 24, false, true);
$response->cacheFor(60 * 15, false, true);
return $response;

}
Expand Down