diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-08-11 22:10:49 +0300 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-08-24 21:21:40 +0300 |
commit | 9498ebac6eccde201526b9a6131a76c02ca5db62 (patch) | |
tree | 7256f1fc6de4dee185f5cc116e45247cf27f28cb /lib/Contracts | |
parent | 430500712496242526eed2aedb5afc42d60ca1b9 (diff) |
Rework the routing
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'lib/Contracts')
-rw-r--r-- | lib/Contracts/IMailManager.php | 70 | ||||
-rw-r--r-- | lib/Contracts/IMailSearch.php | 14 | ||||
-rw-r--r-- | lib/Contracts/IMailTransmission.php | 13 |
3 files changed, 69 insertions, 28 deletions
diff --git a/lib/Contracts/IMailManager.php b/lib/Contracts/IMailManager.php index 553aea52b..212aee8a8 100644 --- a/lib/Contracts/IMailManager.php +++ b/lib/Contracts/IMailManager.php @@ -25,16 +25,28 @@ namespace OCA\Mail\Contracts; use OCA\Mail\Account; use OCA\Mail\Db\Mailbox; +use OCA\Mail\Db\Message; use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Folder; use OCA\Mail\IMAP\FolderStats; use OCA\Mail\Model\IMAPMessage; use OCA\Mail\Service\Quota; +use OCP\AppFramework\Db\DoesNotExistException; interface IMailManager { /** + * @param string $uid + * @param int $id + * + * @return Mailbox + * + * @throws DoesNotExistException + */ + public function getMailbox(string $uid, int $id): Mailbox; + + /** * @param Account $account * * @return Mailbox[] @@ -47,44 +59,63 @@ interface IMailManager { * @param Account $account * @param string $name * - * @return Folder + * @return Mailbox * * @throws ServiceException */ - public function createFolder(Account $account, string $name): Folder; + public function createMailbox(Account $account, string $name): Mailbox; /** * @param Account $account - * @param string $folderId + * @param Mailbox $mailbox * * @return FolderStats + */ + public function getMailboxStats(Account $account, Mailbox $mailbox): FolderStats; + + /** + * @param Mailbox $mailbox + * @param $uid * - * @throws ServiceException + * @return int|null + */ + public function getMessageIdForUid(Mailbox $mailbox, $uid): ?int; + + /** + * @param string $uid + * @param int $id + * + * @return Mailbox + * + * @throws ClientException */ - public function getFolderStats(Account $account, string $folderId): FolderStats; + public function getMessage(string $uid, int $id): Message; /** * @param Account $account * @param string $mb - * @param int $id + * @param int $uid * * @return string * @throws ClientException * @throws ServiceException */ - public function getSource(Account $account, string $mb, int $id): string; + public function getSource(Account $account, string $mb, int $uid): ?string; /** * @param Account $account - * @param string $mailbox - * @param int $id + * @param Mailbox $mailbox + * @param int $uid * @param bool $loadBody * * @return IMAPMessage * * @throws ServiceException */ - public function getMessage(Account $account, string $mailbox, int $id, bool $loadBody = false): IMAPMessage; + public function getImapMessage(Account $account, + Mailbox $mailbox, + int $uid, + bool $loadBody = false): IMAPMessage; /** * @param Account $account @@ -97,14 +128,17 @@ interface IMailManager { /** * @param Account $sourceAccount * @param string $sourceFolderId - * @param int $messageId + * @param int $uid * @param Account $destinationAccount * @param string $destFolderId * * @throws ServiceException */ - public function moveMessage(Account $sourceAccount, string $sourceFolderId, int $messageId, - Account $destinationAccount, string $destFolderId); + public function moveMessage(Account $sourceAccount, + string $sourceFolderId, + int $uid, + Account $destinationAccount, + string $destFolderId); /** * @param Account $account @@ -119,11 +153,9 @@ interface IMailManager { * Mark all messages of a folder as read * * @param Account $account - * @param string $folderId - * - * @throws ServiceException + * @param Mailbox $mailbox */ - public function markFolderAsRead(Account $account, string $folderId): void; + public function markFolderAsRead(Account $account, Mailbox $mailbox): void; /** * @param Account $account @@ -146,9 +178,9 @@ interface IMailManager { /** * @param Account $account - * @param string $folderId + * @param Mailbox $mailbox * * @throws ServiceException */ - public function deleteMailbox(Account $account, string $folderId): void; + public function deleteMailbox(Account $account, Mailbox $mailbox): void; } diff --git a/lib/Contracts/IMailSearch.php b/lib/Contracts/IMailSearch.php index 9487334b2..c751e2c53 100644 --- a/lib/Contracts/IMailSearch.php +++ b/lib/Contracts/IMailSearch.php @@ -26,6 +26,7 @@ declare(strict_types=1); namespace OCA\Mail\Contracts; use OCA\Mail\Account; +use OCA\Mail\Db\Mailbox; use OCA\Mail\Db\Message; use OCA\Mail\Exception\ClientException; use OCA\Mail\Exception\ServiceException; @@ -43,18 +44,25 @@ interface IMailSearch { * @throws ClientException * @throws ServiceException */ - public function findMessage(Account $account, string $mailboxName, int $uid): Message; + public function findMessage(Account $account, + Mailbox $mailbox, + Message $message): Message; /** * @param Account $account - * @param string $mailboxName + * @param Mailbox $mailbox * @param string|null $filter * @param int|null $cursor + * @param int|null $limit * * @return Message[] * * @throws ClientException * @throws ServiceException */ - public function findMessages(Account $account, string $mailboxName, ?string $filter, ?int $cursor, ?int $limit): array; + public function findMessages(Account $account, + Mailbox $mailbox, + ?string $filter, + ?int $cursor, + ?int $limit): array; } diff --git a/lib/Contracts/IMailTransmission.php b/lib/Contracts/IMailTransmission.php index ff1d04138..d4e4c3c57 100644 --- a/lib/Contracts/IMailTransmission.php +++ b/lib/Contracts/IMailTransmission.php @@ -24,6 +24,7 @@ declare(strict_types=1); namespace OCA\Mail\Contracts; use OCA\Mail\Db\Alias; +use OCA\Mail\Db\Message; use OCA\Mail\Exception\ServiceException; use OCA\Mail\Model\NewMessageData; use OCA\Mail\Model\RepliedMessageData; @@ -33,27 +34,27 @@ interface IMailTransmission { /** * Send a new message or reply to an existing one * - * @param string $userId * @param NewMessageData $message - * @param RepliedMessageData $reply + * @param RepliedMessageData|null $reply * @param Alias|null $alias + * @param Message|null $draft * * @throws ServiceException */ public function sendMessage(NewMessageData $message, RepliedMessageData $reply = null, Alias $alias = null, - int $draftUID = null); + Message $draft = null); /** * Save a message draft * * @param NewMessageData $message - * @param int $draftUID + * @param Message|null $previousDraft * - * @return int + * @return array * * @throws ServiceException */ - public function saveDraft(NewMessageData $message, int $draftUID = null): int; + public function saveDraft(NewMessageData $message, Message $previousDraft = null): array; } |