From 9c47e3466bceb221604742be708d8d434d1d7412 Mon Sep 17 00:00:00 2001 From: Andreas Hennings Date: Thu, 14 Nov 2024 01:03:20 +0100 Subject: [PATCH] Issue #56: Rename method and variable for TTL, to clarify it is seconds. --- src/Controller/ViewerController.php | 12 ++++++------ src/Service/CoolJwt.php | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Controller/ViewerController.php b/src/Controller/ViewerController.php index 1b015a95..2bc5d87c 100644 --- a/src/Controller/ViewerController.php +++ b/src/Controller/ViewerController.php @@ -129,18 +129,18 @@ protected function getViewerRender(Media $media, string $wopi_client, bool $can_ $id = $media->id(); - $ttl = $this->coolJwt->getAccessTokenTtl(); - if ($ttl == 0) { - $ttl = 86400; + $ttl_seconds = $this->coolJwt->getTtlSeconds(); + if ($ttl_seconds == 0) { + $ttl_seconds = 86400; } - $access_token = $this->coolJwt->tokenForFileId($id, $ttl, $can_write); + $access_token = $this->coolJwt->tokenForFileId($id, $ttl_seconds, $can_write); $render_array = [ '#wopiClient' => $wopi_client, '#wopiSrc' => urlencode($wopi_base . '/cool/wopi/files/' . $id), '#accessToken' => $access_token, - // It's in usec. The JWT is in sec. - '#accessTokenTtl' => $ttl * 1000, + // Convert to milliseconds. + '#accessTokenTtl' => $ttl_seconds * 1000, '#allowfullscreen' => $allowfullscreen ? 'allowfullscreen' : '', ]; if ($options) { diff --git a/src/Service/CoolJwt.php b/src/Service/CoolJwt.php index a0775292..bdd36eb7 100644 --- a/src/Service/CoolJwt.php +++ b/src/Service/CoolJwt.php @@ -127,7 +127,7 @@ public function tokenForFileId($id, $ttl, $can_write = FALSE) { * @return int * Token TTL in seconds. */ - public function getAccessTokenTtl() { + public function getTtlSeconds() { $default_config = $this->configFactory->get('collabora_online.settings'); $ttl = $default_config->get('cool')['access_token_ttl'];