Skip to content

Commit

Permalink
Try to create the target folder
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Feb 25, 2020
1 parent 2039dbf commit d4383c1
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions lib/Controller/PageController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -69,6 +71,8 @@ class PageController extends Controller {
private $appManager;
/** @var IInitialStateService */
private $initialStateService;
/** @var IRootFolder */
private $rootFolder;
/** @var Config */
private $config;

Expand All @@ -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;
Expand All @@ -96,6 +101,7 @@ public function __construct(string $appName,
$this->notificationManager = $notificationManager;
$this->appManager = $appManager;
$this->initialStateService = $initialStateService;
$this->rootFolder = $rootFolder;
$this->config = $config;
}

Expand Down Expand Up @@ -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),
Expand Down

0 comments on commit d4383c1

Please sign in to comment.