From 7baa7af929d605196f6faff5cdb22fe45c40eabf Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 26 Dec 2023 00:59:30 +0100 Subject: [PATCH] DoMessageCopy() return toFolder hash/etag --- .../app/libraries/MailSo/Mail/MailClient.php | 12 ++++++-- .../libraries/RainLoop/Actions/Messages.php | 30 ++++++------------- 2 files changed, 19 insertions(+), 23 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php index 91fa85b8e..e087b3c43 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/MailClient.php @@ -389,8 +389,16 @@ class MailClient */ public function FolderHash(string $sFolderName) : string { - return $this->oImapClient->FolderStatus($sFolderName)->etag; -// return $this->oImapClient->FolderStatusAndSelect($sFolderName)->etag; + try + { +// 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 ''; } /** diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php index 0dfb90146..c4e565f0f 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Messages.php @@ -61,7 +61,7 @@ trait Messages $oAccount = $this->initMailClientConnection(); if ($sHash) { -// $oInfo = $this->MailClient()->FolderHash($oParams->sFolderName); +// $sFolderHash = $this->MailClient()->FolderHash($oParams->sFolderName); $oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName); $aRequestHash = \explode('-', $sHash); $sFolderHash = $oInfo->etag; @@ -457,15 +457,7 @@ trait Messages throw new ClientException(Notifications::CantDeleteMessage, $oException); } - $sHash = ''; - try - { - $sHash = $this->MailClient()->FolderHash($sFolder); - } - catch (\Throwable $oException) - { - \SnappyMail\Log::warning('IMAP', "FolderHash({$sFolder}) Exception: {$oException->getMessage()}"); - } + $sHash = $this->MailClient()->FolderHash($sFolder); return $this->DefaultResponse($sHash ? array($sFolder, $sHash) : array($sFromFolder)); } @@ -522,15 +514,7 @@ trait Messages throw new ClientException(Notifications::CantMoveMessage, $oException); } - $sHash = ''; - try - { - $sHash = $this->MailClient()->FolderHash($sFromFolder); - } - catch (\Throwable $oException) - { - \SnappyMail\Log::warning('IMAP', "FolderHash({$sFromFolder}) Exception: {$oException->getMessage()}"); - } + $sHash = $this->MailClient()->FolderHash($sFromFolder); return $this->DefaultResponse($sHash ? array($sFromFolder, $sHash) : array($sFromFolder)); } @@ -542,11 +526,13 @@ trait Messages { $this->initMailClientConnection(); + $sToFolder = $this->GetActionParam('toFolder', ''); + try { $this->ImapClient()->MessageCopy( $this->GetActionParam('fromFolder', ''), - $this->GetActionParam('toFolder', ''), + $sToFolder, new SequenceSet(\explode(',', (string) $this->GetActionParam('uids', ''))) ); } @@ -555,7 +541,9 @@ trait Messages 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