Reduce IMAP CAPABILITY requests

This commit is contained in:
djmaze 2021-11-04 15:16:35 +01:00
parent e0f0ea7c46
commit d961d8e836

View file

@ -290,8 +290,10 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function Capability() : ?array public function Capability() : ?array
{ {
$this->aCapabilityItems = $this->SendRequestGetResponse('CAPABILITY') if (!$this->aCapabilityItems) {
->getCapabilityResult(); $this->aCapabilityItems = $this->SendRequestGetResponse('CAPABILITY')
->getCapabilityResult();
}
return $this->aCapabilityItems; return $this->aCapabilityItems;
} }
@ -311,11 +313,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function IsSupported(string $sExtentionName) : bool public function IsSupported(string $sExtentionName) : bool
{ {
$sExtentionName = \trim($sExtentionName); $sExtentionName = \trim($sExtentionName);
if ($sExtentionName && null === $this->aCapabilityItems) { return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->Capability() ?: []);
$this->aCapabilityItems = $this->Capability();
}
return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->aCapabilityItems ?: []);
} }
/** /**
@ -346,7 +344,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function AppendLimit() : ?int public function AppendLimit() : ?int
{ {
if ($this->aCapabilityItems) { if ($this->Capability()) {
foreach ($this->aCapabilityItems as $string) { foreach ($this->aCapabilityItems as $string) {
if ('APPENDLIMIT=' === \substr($string, 0, 12)) { if ('APPENDLIMIT=' === \substr($string, 0, 12)) {
return (int) \substr($string, 12); return (int) \substr($string, 12);