Skip to content

Commit

Permalink
Issue CollaboraOnline#56: Rename method and variable for TTL, to clar…
Browse files Browse the repository at this point in the history
…ify it is seconds.
  • Loading branch information
donquixote committed Nov 21, 2024
1 parent cc05818 commit f16e341
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/Controller/ViewerController.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,18 +130,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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Service/CoolJwt.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'];

Expand Down

0 comments on commit f16e341

Please sign in to comment.