DoMessageCopy() return toFolder hash/etag

This commit is contained in:
the-djmaze 2023-12-26 00:59:30 +01:00
parent 508f5cc6e5
commit 7baa7af929
2 changed files with 19 additions and 23 deletions

View file

@ -389,8 +389,16 @@ class MailClient
*/ */
public function FolderHash(string $sFolderName) : string public function FolderHash(string $sFolderName) : string
{ {
return $this->oImapClient->FolderStatus($sFolderName)->etag; try
// return $this->oImapClient->FolderStatusAndSelect($sFolderName)->etag; {
// return $this->oImapClient->FolderStatusAndSelect($sFolderName)->etag;
return $this->oImapClient->FolderStatus($sFolderName)->etag;
}
catch (\Throwable $oException)
{
\SnappyMail\Log::warning('IMAP', "FolderHash({$sFolderName}) Exception: {$oException->getMessage()}");
}
return '';
} }
/** /**

View file

@ -61,7 +61,7 @@ trait Messages
$oAccount = $this->initMailClientConnection(); $oAccount = $this->initMailClientConnection();
if ($sHash) { if ($sHash) {
// $oInfo = $this->MailClient()->FolderHash($oParams->sFolderName); // $sFolderHash = $this->MailClient()->FolderHash($oParams->sFolderName);
$oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName); $oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName);
$aRequestHash = \explode('-', $sHash); $aRequestHash = \explode('-', $sHash);
$sFolderHash = $oInfo->etag; $sFolderHash = $oInfo->etag;
@ -457,15 +457,7 @@ trait Messages
throw new ClientException(Notifications::CantDeleteMessage, $oException); throw new ClientException(Notifications::CantDeleteMessage, $oException);
} }
$sHash = ''; $sHash = $this->MailClient()->FolderHash($sFolder);
try
{
$sHash = $this->MailClient()->FolderHash($sFolder);
}
catch (\Throwable $oException)
{
\SnappyMail\Log::warning('IMAP', "FolderHash({$sFolder}) Exception: {$oException->getMessage()}");
}
return $this->DefaultResponse($sHash ? array($sFolder, $sHash) : array($sFromFolder)); return $this->DefaultResponse($sHash ? array($sFolder, $sHash) : array($sFromFolder));
} }
@ -522,15 +514,7 @@ trait Messages
throw new ClientException(Notifications::CantMoveMessage, $oException); throw new ClientException(Notifications::CantMoveMessage, $oException);
} }
$sHash = ''; $sHash = $this->MailClient()->FolderHash($sFromFolder);
try
{
$sHash = $this->MailClient()->FolderHash($sFromFolder);
}
catch (\Throwable $oException)
{
\SnappyMail\Log::warning('IMAP', "FolderHash({$sFromFolder}) Exception: {$oException->getMessage()}");
}
return $this->DefaultResponse($sHash ? array($sFromFolder, $sHash) : array($sFromFolder)); return $this->DefaultResponse($sHash ? array($sFromFolder, $sHash) : array($sFromFolder));
} }
@ -542,11 +526,13 @@ trait Messages
{ {
$this->initMailClientConnection(); $this->initMailClientConnection();
$sToFolder = $this->GetActionParam('toFolder', '');
try try
{ {
$this->ImapClient()->MessageCopy( $this->ImapClient()->MessageCopy(
$this->GetActionParam('fromFolder', ''), $this->GetActionParam('fromFolder', ''),
$this->GetActionParam('toFolder', ''), $sToFolder,
new SequenceSet(\explode(',', (string) $this->GetActionParam('uids', ''))) new SequenceSet(\explode(',', (string) $this->GetActionParam('uids', '')))
); );
} }
@ -555,7 +541,9 @@ trait Messages
throw new ClientException(Notifications::CantCopyMessage, $oException); throw new ClientException(Notifications::CantCopyMessage, $oException);
} }
return $this->TrueResponse(); $sHash = $this->MailClient()->FolderHash($sToFolder);
return $this->DefaultResponse($sHash ? array($sToFolder, $sHash) : array($sToFolder));
} }
public function DoMessageUploadAttachments() : array public function DoMessageUploadAttachments() : array