From 9fbde56e0177ca366eb7f8f881b9f2a70d17083c Mon Sep 17 00:00:00 2001 From: djmaze Date: Wed, 27 Oct 2021 22:44:24 +0200 Subject: [PATCH] Make IMAP LIST-STATUS extension optional so you can turn it off on slow servers. See application.ini `imap_use_list_status` --- .../release/files/usr/local/include/application.ini | 1 + .../v/0.0.0/app/libraries/MailSo/Mail/MailClient.php | 11 +++++++---- .../0.0.0/app/libraries/RainLoop/Actions/Folders.php | 3 ++- .../app/libraries/RainLoop/Config/Application.php | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.docker/release/files/usr/local/include/application.ini b/.docker/release/files/usr/local/include/application.ini index 4bd080a70..f67782673 100644 --- a/.docker/release/files/usr/local/include/application.ini +++ b/.docker/release/files/usr/local/include/application.ini @@ -254,6 +254,7 @@ imap_folder_list_limit = 200 imap_show_login_alert = On imap_use_auth_plain = On imap_use_auth_cram_md5 = Off +imap_use_list_status = On smtp_show_server_errors = Off smtp_use_auth_plain = On smtp_use_auth_cram_md5 = Off 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 1002f0e10..f7e249082 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 @@ -1911,7 +1911,7 @@ class MailClient return $aMailFoldersHelper; } - public function Folders(string $sParent = '', string $sListPattern = '*', bool $bUseListSubscribeStatus = true, int $iOptimizationLimit = 0) : ?FolderCollection + public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus, int $iOptimizationLimit, bool $bUseListStatus) : ?FolderCollection { $aImapSubscribedFoldersHelper = null; if ($this->oImapClient->IsSupported('LIST-EXTENDED')) { @@ -1933,8 +1933,11 @@ class MailClient } } -// $aFolders = $this->oImapClient->FolderList($sParent, $sListPattern); - $aFolders = $this->oImapClient->FolderStatusList($sParent, $sListPattern); + $bUseListStatus = $bUseListStatus && $this->oImapClient->IsSupported('LIST-STATUS'); + + $aFolders = $bUseListStatus + ? $this->oImapClient->FolderStatusList($sParent, $sListPattern) + : $this->oImapClient->FolderList($sParent, $sListPattern); if (!$aFolders) { return null; } @@ -1958,7 +1961,7 @@ class MailClient $oFolderCollection->IsMetadataSupported = $this->oImapClient->IsSupported('METADATA'); $oFolderCollection->IsThreadsSupported = $this->IsThreadsSupported(); $oFolderCollection->IsSortSupported = $this->oImapClient->IsSupported('SORT'); - $oFolderCollection->IsListStatusSupported = $this->oImapClient->IsSupported('LIST-STATUS'); + $oFolderCollection->IsListStatusSupported = $bUseListStatus; $oFolderCollection->Optimized = $iCount !== \count($aMailFoldersHelper); $aSortedByLenImapFolders = array(); 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 a4fd5aaea..a6c7a5f9c 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 @@ -14,7 +14,8 @@ trait Folders { return $this->MailClient()->Folders('', '*', $HideUnsubscribed, - (int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200) + (int) $this->Config()->Get('labs', 'imap_folder_list_limit', 200), + (bool) $this->Config()->Get('labs', 'imap_use_list_status', true) ); } diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php index 1bb747f2a..544d9de1d 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Config/Application.php @@ -338,6 +338,7 @@ Enables caching in the system'), 'imap_show_login_alert' => array(true), 'imap_use_auth_plain' => array(true), 'imap_use_auth_cram_md5' => array(false), + 'imap_use_list_status' => array(true), 'smtp_show_server_errors' => array(false), 'smtp_use_auth_plain' => array(true), 'smtp_use_auth_cram_md5' => array(false),