From c46ca8a03a6c76b137d2a5b69974b82b0aa83569 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julius=20H=C3=A4rtl?= Date: Fri, 5 Aug 2022 13:20:41 +0200 Subject: [PATCH] Fetch attachment folder for the correct user during cron job MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- lib/Service/ConfigService.php | 4 ++-- lib/Sharing/Listener.php | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Service/ConfigService.php b/lib/Service/ConfigService.php index cca6265bf..5aca2222c 100644 --- a/lib/Service/ConfigService.php +++ b/lib/Service/ConfigService.php @@ -169,11 +169,11 @@ class ConfigService { return array_filter($groups); } - public function getAttachmentFolder(): string { + public function getAttachmentFolder(string $userId = null): string { if ($this->getUserId() === null) { throw new NoPermissionException('Must be logged in get the attachment folder'); } - return $this->config->getUserValue($this->getUserId(), 'deck', 'attachment_folder', '/Deck'); + return $this->config->getUserValue($userId ?? $this->getUserId(), 'deck', 'attachment_folder', '/Deck'); } } diff --git a/lib/Sharing/Listener.php b/lib/Sharing/Listener.php index 8fa954fcd..49e1651e7 100644 --- a/lib/Sharing/Listener.php +++ b/lib/Sharing/Listener.php @@ -102,7 +102,7 @@ class Listener { } } - $parent = $this->configService->getAttachmentFolder(); + $parent = $this->configService->getAttachmentFolder($userId); $event->setParent($parent); if (!$event->getView()->is_dir($parent)) { $event->getView()->mkdir($parent);