diff --git a/dev/Remote/User/Fetch.js b/dev/Remote/User/Fetch.js index 8217f83b2..05fd3f1b6 100644 --- a/dev/Remote/User/Fetch.js +++ b/dev/Remote/User/Fetch.js @@ -800,6 +800,13 @@ class RemoteUserFetch extends AbstractFetchRemote { }); } + folderMove(sPrevFolderFullNameRaw, sNewFolderFullName) { + return this.postRequest('FolderMove', FolderUserStore.foldersRenaming, { + Folder: sPrevFolderFullNameRaw, + NewFolder: sNewFolderFullName + }); + } + folderRename(sPrevFolderFullNameRaw, sNewFolderName) { return this.postRequest('FolderRename', FolderUserStore.foldersRenaming, { Folder: sPrevFolderFullNameRaw, 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 76d24fbd0..e7bad6d30 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 @@ -2088,7 +2088,7 @@ class MailClient /** * @throws \MailSo\Base\Exceptions\InvalidArgumentException */ - public function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRenameOrMove, bool $bSubscribeOnModify) : self + protected function folderModify(string $sPrevFolderFullNameRaw, string $sNextFolderNameInUtf, bool $bRename, bool $bSubscribeOnModify) : self { if (0 === \strlen($sPrevFolderFullNameRaw) || 0 === \strlen($sNextFolderNameInUtf)) { @@ -2099,7 +2099,7 @@ class MailClient if (!$aFolders) { // TODO - throw new \MailSo\Mail\Exceptions\RuntimeException('Cannot rename non-existen folder'); + throw new \MailSo\Mail\Exceptions\RuntimeException('Cannot '.($bRename?'rename':'move').' non-existen folder'); } $sDelimiter = $aFolders[0]->Delimiter(); @@ -2119,7 +2119,7 @@ class MailClient \MailSo\Base\Enumerations\Charset::UTF_8, \MailSo\Base\Enumerations\Charset::UTF_7_IMAP); - if ($bRenameOrMove) + if ($bRename) { if (0 < \strlen($sDelimiter) && false !== \strpos($sNewFolderFullNameRaw, $sDelimiter)) { diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Folders.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Folders.php index f42e9ca04..8240814a9 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Folders.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Folders.php @@ -239,6 +239,29 @@ trait Folders $this->SettingsProvider(true)->Save($oAccount, $oSettingsLocal)); } + /** + * @throws \MailSo\Base\Exceptions\Exception + */ + public function DoFolderMove() : array + { + $oAccount = $this->initMailClientConnection(); + + try + { + $this->MailClient()->FolderMove( + $this->GetActionParam('Folder', ''), + $this->GetActionParam('NewFolder', ''), + !!$this->Config()->Get('labs', 'use_imap_list_subscribe', true) + ); + } + catch (\Throwable $oException) + { + throw new ClientException(Notifications::CantRenameFolder, $oException); + } + + return $this->TrueResponse(__FUNCTION__); + } + /** * @throws \MailSo\Base\Exceptions\Exception */ @@ -246,13 +269,13 @@ trait Folders { $oAccount = $this->initMailClientConnection(); - $sPrevFolderFullNameRaw = $this->GetActionParam('Folder', ''); - $sNewTopFolderNameInUtf = $this->GetActionParam('NewFolderName', ''); - try { - $this->MailClient()->FolderRename($sPrevFolderFullNameRaw, $sNewTopFolderNameInUtf, - !!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)); + $this->MailClient()->FolderRename( + $this->GetActionParam('Folder', ''), + $this->GetActionParam('NewFolderName', ''), + !!$this->Config()->Get('labs', 'use_imap_list_subscribe', true) + ); } catch (\Throwable $oException) { @@ -269,12 +292,12 @@ trait Folders { $oAccount = $this->initMailClientConnection(); - $sFolderFullNameRaw = $this->GetActionParam('Folder', ''); - try { - $this->MailClient()->FolderDelete($sFolderFullNameRaw, - !!$this->Config()->Get('labs', 'use_imap_list_subscribe', true)); + $this->MailClient()->FolderDelete( + $this->GetActionParam('Folder', ''), + !!$this->Config()->Get('labs', 'use_imap_list_subscribe', true) + ); } catch (\MailSo\Mail\Exceptions\NonEmptyFolder $oException) { @@ -295,11 +318,9 @@ trait Folders { $this->initMailClientConnection(); - $sFolderFullNameRaw = $this->GetActionParam('Folder', ''); - try { - $this->MailClient()->FolderClear($sFolderFullNameRaw); + $this->MailClient()->FolderClear($this->GetActionParam('Folder', '')); } catch (\Throwable $oException) {