From 0ea4b78c91577cebb8d17c080f6699d2b1b9cd16 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 38d3db73..aa0fa567 100644 --- a/src/Controller/ViewerController.php +++ b/src/Controller/ViewerController.php @@ -128,18 +128,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 7e0aa5dc..7c173e28 100644 --- a/src/Service/CoolJwt.php +++ b/src/Service/CoolJwt.php @@ -130,7 +130,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'];