Added IMAP FolderHierarchyDelimiter() to easily fetch the delimiter

This commit is contained in:
djmaze 2021-10-28 11:17:18 +02:00
parent 371797cab1
commit 0ba7d3979a
2 changed files with 13 additions and 3 deletions

View file

@ -527,6 +527,16 @@ class ImapClient extends \MailSo\Net\NetClient
return $this->specificFolderList(false, $sParentFolderName, $sListPattern, true);
}
/**
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderHierarchyDelimiter(string $sFolderName = '') : ?string
{
$oResponse = $this->SendRequestGetResponse('LIST', ['""', $this->EscapeString($sParentFolderName)]);
return ('LIST' === $oResponse[0]->ResponseList[1]) ? $oResponse[0]->ResponseList[3] : null;
}
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Net\Exceptions\Exception

View file

@ -2056,8 +2056,8 @@ class MailClient
if (!\strlen($sDelimiter) || \strlen($sFolderParentFullNameRaw))
{
$aFolders = $this->oImapClient->FolderList('', \strlen($sFolderParentFullNameRaw) ? $sFolderParentFullNameRaw : 'INBOX');
if (!$aFolders)
$sDelimiter = $this->oImapClient->FolderHierarchyDelimiter($sFolderParentFullNameRaw);
if (null === $sDelimiter)
{
// TODO: Translate
throw new Exceptions\RuntimeException(
@ -2066,7 +2066,6 @@ class MailClient
: 'Cannot get folder delimiter.');
}
$sDelimiter = $aFolders[0]->Delimiter();
if (\strlen($sDelimiter) && \strlen($sFolderParentFullNameRaw))
{
$sFolderParentFullNameRaw .= $sDelimiter;
@ -2114,6 +2113,7 @@ class MailClient
/**
* @throws \MailSo\Base\Exceptions\InvalidArgumentException
* @throws \MailSo\Base\Exceptions\RuntimeException
*/
protected function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self
{