Merge quota requests into folders request

This commit is contained in:
djmaze 2021-11-01 16:26:07 +01:00
parent 20eb01de08
commit 8d3bcdc2f2
9 changed files with 45 additions and 51 deletions

View file

@ -743,7 +743,7 @@ class ImapClient extends \MailSo\Net\NetClient
*
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
* /
*/
public function Quota(string $sRootName = '') : ?array
{
if ($this->IsSupported('QUOTA'))
@ -753,7 +753,6 @@ class ImapClient extends \MailSo\Net\NetClient
return null;
}
*/
/**
* https://datatracker.ietf.org/doc/html/rfc2087#section-4.3

View file

@ -57,6 +57,9 @@ class FolderCollection extends \MailSo\Base\Collection
*/
public $SystemFolders = array();
public $quotaUsage = 0;
public $quotaLimit = 0;
public function append($oFolder, bool $bToTop = false) : void
{
assert($oFolder instanceof Folder);
@ -149,6 +152,8 @@ class FolderCollection extends \MailSo\Base\Collection
'IsThreadsSupported' => $this->IsThreadsSupported,
'IsSortSupported' => $this->IsSortSupported,
'IsListStatusSupported' => $this->IsListStatusSupported,
'quotaUsage' => $this->quotaUsage,
'quotaLimit' => $this->quotaLimit,
'Optimized' => $this->Optimized,
'CountRec' => $this->CountRec(),
'SystemFolders' => empty($this->SystemFolders) ? null : $this->SystemFolders

View file

@ -1771,6 +1771,11 @@ class MailClient
return $oMessageCollection;
}
public function Quota(string $sRootName = '') : ?array
{
return $this->oImapClient->Quota($sRootName);
}
public function QuotaRoot(string $sFolderName = 'INBOX') : ?array
{
return $this->oImapClient->QuotaRoot($sFolderName);

View file

@ -12,11 +12,27 @@ trait Folders
private function getFolderCollection(bool $HideUnsubscribed) : ?\MailSo\Mail\FolderCollection
{
return $this->MailClient()->Folders('', '*',
$oFolderCollection = $this->MailClient()->Folders('', '*',
$HideUnsubscribed,
(int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200),
(bool) $this->Config()->Get('labs', 'imap_use_list_status', true)
);
if ($oFolderCollection) {
$oAccount = $this->getAccountFromToken();
if ($this->GetCapa(false, Capa::QUOTA, $oAccount)) {
try {
$aQuota = $this->MailClient()->Quota();
// $aQuota = $this->MailClient()->QuotaRoot();
$oFolderCollection->quotaUsage = $aQuota[0] * 1024;
$oFolderCollection->quotaLimit = $aQuota[1] * 1024;
} catch (\Throwable $oException) {
// ignore
}
}
}
return $oFolderCollection;
}
public function DoFolders() : array