Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions js/editor-collab.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/editor-collab.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/files.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/public.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/public.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/text.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion js/viewer.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions lib/Db/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
use OCP\AppFramework\Db\Entity;

/**
* @method int getLastContact()
* @method setLastContact(int $getTime)
* @method getDocumentId()
* @method getUserId()
Expand Down
22 changes: 18 additions & 4 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ public function getSession($documentId, $sessionId, $token) {

try {
$data = $this->sessionMapper->find($documentId, $sessionId, $token);
$this->cache->set($token, json_encode($data), self::SESSION_VALID_TIME);
$this->cache->set($token, json_encode($data), self::SESSION_VALID_TIME - 30);
return $data;
} catch (DoesNotExistException $e) {
$this->session = false;
Expand All @@ -178,9 +178,23 @@ public function isValidSession($documentId, $sessionId, $token): bool {
return false;
}

$session->setLastContact($this->timeFactory->getTime());
$this->sessionMapper->update($session);
$this->cache->set($token, json_encode($session), self::SESSION_VALID_TIME);
$currentTime = $this->timeFactory->getTime();
if (($currentTime - $session->getLastContact()) >= 30) {
/*
* We need to update the timestamp.
* Make sure that the session we got is still in the database
*/
try {
$session = $this->sessionMapper->find($documentId, $sessionId, $token);
} catch (DoesNotExistException $e) {
$this->session = false;
$this->cache->remove($token);
return false;
}
$session->setLastContact($this->timeFactory->getTime());
$this->sessionMapper->update($session);
$this->cache->set($token, json_encode($session), self::SESSION_VALID_TIME - 30);
}
return true;
}

Expand Down
4 changes: 2 additions & 2 deletions src/components/SessionList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ import PopoverMenu from '@nextcloud/vue/dist/Components/PopoverMenu'
import Tooltip from '@nextcloud/vue/dist/Directives/Tooltip'
import { generateUrl } from '@nextcloud/router'

const COLLABORATOR_IDLE_TIME = 10
const COLLABORATOR_DISCONNECT_TIME = 30
const COLLABORATOR_IDLE_TIME = 60
const COLLABORATOR_DISCONNECT_TIME = 90

export default {
name: 'SessionList',
Expand Down