Skip to content

Commit

Permalink
always use DEFAULT_SPACEDECK_API_KEY with local embedded server
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Veyssier <eneiluj@posteo.net>
  • Loading branch information
Julien Veyssier committed May 3, 2022
1 parent 9dfc2bf commit 5c975c4
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 9 deletions.
3 changes: 1 addition & 2 deletions lib/BackgroundJob/CleanupSpacedeck.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ protected function run($argument): void {

$useLocalSpacedeck = $this->config->getAppValue(Application::APP_ID, 'use_local_spacedeck', '1') === '1';
if ($useLocalSpacedeck) {
$apiToken = $this->config->getAppValue(Application::APP_ID, 'api_token', DEFAULT_SPACEDECK_API_KEY);
$apiToken = $apiToken ?: DEFAULT_SPACEDECK_API_KEY;
$apiToken = DEFAULT_SPACEDECK_API_KEY;
$baseUrl = $this->config->getAppValue(Application::APP_ID, 'base_url', DEFAULT_SPACEDECK_URL);
$baseUrl = $baseUrl ?: DEFAULT_SPACEDECK_URL;

Expand Down
3 changes: 1 addition & 2 deletions lib/Command/CleanupSpacedeck.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ protected function execute(InputInterface $input, OutputInterface $output) {
// \OC_Util::setupFS('');
$useLocalSpacedeck = $this->config->getAppValue(Application::APP_ID, 'use_local_spacedeck', '1') === '1';
if ($useLocalSpacedeck) {
$apiToken = $this->config->getAppValue(Application::APP_ID, 'api_token', DEFAULT_SPACEDECK_API_KEY);
$apiToken = $apiToken ?: DEFAULT_SPACEDECK_API_KEY;
$apiToken = DEFAULT_SPACEDECK_API_KEY;
$baseUrl = $this->config->getAppValue(Application::APP_ID, 'base_url', DEFAULT_SPACEDECK_URL);
$baseUrl = $baseUrl ?: DEFAULT_SPACEDECK_URL;

Expand Down
5 changes: 3 additions & 2 deletions lib/Controller/SpacedeckAPIController.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,16 @@ public function __construct(string $AppName,
$this->config = $config;
$this->logger = $logger;
$this->spacedeckApiService = $spacedeckApiService;
$this->apiToken = $this->config->getAppValue(Application::APP_ID, 'api_token', DEFAULT_SPACEDECK_API_KEY);
$this->apiToken = $this->apiToken ?: DEFAULT_SPACEDECK_API_KEY;

$this->useLocalSpacedeck = $this->config->getAppValue(Application::APP_ID, 'use_local_spacedeck', '1') === '1';
if ($this->useLocalSpacedeck) {
$this->baseUrl = DEFAULT_SPACEDECK_URL;
$this->apiToken = DEFAULT_SPACEDECK_API_KEY;
} else {
$this->baseUrl = $this->config->getAppValue(Application::APP_ID, 'base_url', DEFAULT_SPACEDECK_URL);
$this->baseUrl = $this->baseUrl ?: DEFAULT_SPACEDECK_URL;
$this->apiToken = $this->config->getAppValue(Application::APP_ID, 'api_token', DEFAULT_SPACEDECK_API_KEY);
$this->apiToken = $this->apiToken ?: DEFAULT_SPACEDECK_API_KEY;
}
$this->fileService = $fileService;
$this->sessionService = $sessionService;
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/SessionService.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,21 @@ public function checkSessionPermissions(string $sessionToken, string $method): i
if ($session['token_type'] === Application::TOKEN_TYPES['user']) {
$perm = $this->fileService->getUserPermissionsOnFile($session['editor_uid'], $session['file_id']);
if ($method !== 'GET' && $perm === Application::PERMISSIONS['edit']) {
$this->spaceSessionSpaceToFile($session);
$this->saveSessionSpaceToFile($session);
}
return $perm;
} else {
$perm = $this->fileService->getSharePermissionsOnFile($session['share_token'], $session['file_id']);
if ($method !== 'GET' && $perm === Application::PERMISSIONS['edit']) {
$this->spaceSessionSpaceToFile($session);
$this->saveSessionSpaceToFile($session);
}
return $perm;
}
}
return Application::PERMISSIONS['none'];
}

private function spaceSessionSpaceToFile(array $session) {
private function saveSessionSpaceToFile(array $session) {
try {
$baseUrl = $this->config->getAppValue(Application::APP_ID, 'base_url', DEFAULT_SPACEDECK_URL);
$apiToken = $this->config->getAppValue(Application::APP_ID, 'api_token', DEFAULT_SPACEDECK_API_KEY);
Expand Down

0 comments on commit 5c975c4

Please sign in to comment.