diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-02-03 16:51:51 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-02-03 22:24:27 +0300 |
commit | 6d2d36a1982f851aead5acb7a861601e7881ccae (patch) | |
tree | cff597c6126f2e6d0fcff1be88d29f98ca5399cb /lib/Controller | |
parent | 70962a95ac6bf61079976c13380d809ef754ef6a (diff) |
Detect missing mailbox cache and block access to messages
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Controller')
-rw-r--r-- | lib/Controller/FoldersController.php | 7 | ||||
-rwxr-xr-x | lib/Controller/MessagesController.php | 13 |
2 files changed, 7 insertions, 13 deletions
diff --git a/lib/Controller/FoldersController.php b/lib/Controller/FoldersController.php index 3caa7c051..96442b68f 100644 --- a/lib/Controller/FoldersController.php +++ b/lib/Controller/FoldersController.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Mail\Controller; use Horde_Imap_Client; +use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\MailboxNotCachedException; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Service\SyncService; @@ -102,10 +103,12 @@ class FoldersController extends Controller { * @param string $folderId * @param string $syncToken * @param int[] $uids + * * @return JSONResponse + * @throws ClientException * @throws ServiceException */ - public function sync(int $accountId, string $folderId, array $uids = []): JSONResponse { + public function sync(int $accountId, string $folderId, array $uids = [], bool $init = false): JSONResponse { $account = $this->accountService->find($this->currentUserId, $accountId); if (empty($accountId) || empty($folderId) || !is_array($uids)) { @@ -120,7 +123,7 @@ class FoldersController extends Controller { array_map(function($uid) { return (int) $uid; }, $uids), - true + !$init ); } catch (MailboxNotCachedException $e) { return new JSONResponse(null, Http::STATUS_PRECONDITION_REQUIRED); diff --git a/lib/Controller/MessagesController.php b/lib/Controller/MessagesController.php index 7e075621e..9a6fc82de 100755 --- a/lib/Controller/MessagesController.php +++ b/lib/Controller/MessagesController.php @@ -33,6 +33,7 @@ namespace OCA\Mail\Controller; use Exception; use OCA\Mail\Contracts\IMailManager; use OCA\Mail\Contracts\IMailSearch; +use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Http\AttachmentDownloadResponse; use OCA\Mail\Http\HtmlResponse; @@ -40,7 +41,6 @@ use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\AccountService; use OCA\Mail\Service\IMailBox; use OCA\Mail\Service\ItineraryService; -use OCA\Mail\Service\SyncService; use OCP\AppFramework\Controller; use OCP\AppFramework\Db\DoesNotExistException; use OCP\AppFramework\Http; @@ -70,9 +70,6 @@ class MessagesController extends Controller { /** @var ItineraryService */ private $itineraryService; - /** @var SyncService */ - private $syncService; - /** @var string */ private $currentUserId; @@ -108,7 +105,6 @@ class MessagesController extends Controller { IMailManager $mailManager, IMailSearch $mailSearch, ItineraryService $itineraryService, - SyncService $syncService, string $UserId, $userFolder, ILogger $logger, @@ -121,7 +117,6 @@ class MessagesController extends Controller { $this->mailManager = $mailManager; $this->mailSearch = $mailSearch; $this->itineraryService = $itineraryService; - $this->syncService = $syncService; $this->currentUserId = $UserId; $this->userFolder = $userFolder; $this->logger = $logger; @@ -141,6 +136,7 @@ class MessagesController extends Controller { * @param string $filter * * @return JSONResponse + * @throws ClientException * @throws ServiceException */ public function index(int $accountId, string $folderId, int $cursor = null, string $filter = null): JSONResponse { @@ -150,11 +146,6 @@ class MessagesController extends Controller { return new JSONResponse(null, Http::STATUS_FORBIDDEN); } - $this->syncService->ensurePopulated( - $account, - base64_decode($folderId) - ); - $this->logger->debug("loading messages of folder <$folderId>"); return new JSONResponse( |