From 6e1cf74908e06a74932fd7daf51c6e635adb17cf Mon Sep 17 00:00:00 2001 From: djmaze Date: Wed, 3 Nov 2021 12:09:43 +0100 Subject: [PATCH] Make IMAP QUOTA rfc2087 a trait --- .../libraries/MailSo/Imap/Commands/Quota.php | 48 +++++++++++++++++++ .../app/libraries/MailSo/Imap/ImapClient.php | 34 +------------ 2 files changed, 50 insertions(+), 32 deletions(-) create mode 100644 snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/Quota.php diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/Quota.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/Quota.php new file mode 100644 index 000000000..9915d751b --- /dev/null +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/Quota.php @@ -0,0 +1,48 @@ +IsSupported('QUOTA') + ? $this->SendRequestGetResponse("GETQUOTA {$this->EscapeString($sRootName)}")->getQuotaResult() + : null; + } + + /** + * https://datatracker.ietf.org/doc/html/rfc2087#section-4.3 + * + * @throws \MailSo\Net\Exceptions\Exception + * @throws \MailSo\Imap\Exceptions\Exception + */ + public function QuotaRoot(string $sFolderName = 'INBOX') : ?array + { + return $this->IsSupported('QUOTA') + ? $this->SendRequestGetResponse("GETQUOTAROOT {$this->EscapeString($sFolderName)}")->getQuotaResult() + : null; + } +} diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index 2012fbb19..5abf705ae 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -20,6 +20,7 @@ class ImapClient extends \MailSo\Net\NetClient use Traits\ResponseParser; // use Commands\ACL; use Commands\Metadata; + use Commands\Quota; const TAG_PREFIX = 'TAG'; @@ -739,38 +740,6 @@ class ImapClient extends \MailSo\Net\NetClient return $oResult->getFetchResult($this->oLogger); } - /** - * https://datatracker.ietf.org/doc/html/rfc2087#section-4.2 - * - * @throws \MailSo\Net\Exceptions\Exception - * @throws \MailSo\Imap\Exceptions\Exception - */ - public function Quota(string $sRootName = '') : ?array - { - if ($this->IsSupported('QUOTA')) - { - return $this->SendRequestGetResponse("GETQUOTA {$this->EscapeString($sRootName)}")->getQuotaResult(); - } - - return null; - } - - /** - * https://datatracker.ietf.org/doc/html/rfc2087#section-4.3 - * - * @throws \MailSo\Net\Exceptions\Exception - * @throws \MailSo\Imap\Exceptions\Exception - */ - public function QuotaRoot(string $sFolderName = 'INBOX') : ?array - { - if ($this->IsSupported('QUOTA')) - { - return $this->SendRequestGetResponse("GETQUOTAROOT {$this->EscapeString($sFolderName)}")->getQuotaResult(); - } - - return null; - } - /** * See https://tools.ietf.org/html/rfc5256 * @throws \MailSo\Base\Exceptions\InvalidArgumentException @@ -1200,6 +1169,7 @@ class ImapClient extends \MailSo\Net\NetClient } /** + * RFC 2971 * Don't have to be logged in to call this command */ public function ServerID() : string