From d4383c15d3917b110917f50f39b2cebb4da9d2a1 Mon Sep 17 00:00:00 2001 From: Joas Schilling Date: Fri, 21 Feb 2020 13:57:51 +0100 Subject: [PATCH] Try to create the target folder Signed-off-by: Joas Schilling --- lib/Controller/PageController.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/Controller/PageController.php b/lib/Controller/PageController.php index 48b5b3d0255..30c642c4fc0 100644 --- a/lib/Controller/PageController.php +++ b/lib/Controller/PageController.php @@ -40,6 +40,8 @@ use OCP\AppFramework\Http\Response; use OCP\AppFramework\Http\TemplateResponse; use OCP\AppFramework\Http\Template\PublicTemplateResponse; +use OCP\Files\IRootFolder; +use OCP\Files\NotPermittedException; use OCP\IInitialStateService; use OCP\ILogger; use OCP\IRequest; @@ -69,6 +71,8 @@ class PageController extends Controller { private $appManager; /** @var IInitialStateService */ private $initialStateService; + /** @var IRootFolder */ + private $rootFolder; /** @var Config */ private $config; @@ -84,6 +88,7 @@ public function __construct(string $appName, INotificationManager $notificationManager, IAppManager $appManager, IInitialStateService $initialStateService, + IRootFolder $rootFolder, Config $config) { parent::__construct($appName, $request); $this->api = $api; @@ -96,6 +101,7 @@ public function __construct(string $appName, $this->notificationManager = $notificationManager; $this->appManager = $appManager; $this->initialStateService = $initialStateService; + $this->rootFolder = $rootFolder; $this->config = $config; } @@ -211,11 +217,22 @@ public function index(string $token = '', string $callUser = '', string $passwor $this->appManager->isEnabledForUser('circles', $user) ); + $attachmentFolder = $this->config->getAttachmentFolder($user->getUID()); $this->initialStateService->provideInitialState( 'talk', 'attachment_folder', $this->config->getAttachmentFolder($user->getUID()) ); + if ($attachmentFolder) { + $userFolder = $this->rootFolder->getUserFolder($user->getUID()); + if (!$userFolder->nodeExists($attachmentFolder)) { + try { + $userFolder->newFolder($attachmentFolder); + } catch (NotPermittedException $e) { + } + } + } + $params = [ 'token' => $token, 'signaling-settings' => $this->config->getSettings($this->userId),