mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-09 17:37:02 +03:00
Revamp Domains Settings IMAP disabled capabilities to extend it
This commit is contained in:
parent
e6b2cdfcdf
commit
cf910c678b
10 changed files with 349 additions and 249 deletions
|
|
@ -22,14 +22,10 @@
|
|||
"disable_compression": true,
|
||||
"security_level": 1
|
||||
},
|
||||
"disable_list_status": false,
|
||||
"disable_metadata": false,
|
||||
"disable_move": false,
|
||||
"disable_sort": false,
|
||||
"disable_thread": false,
|
||||
"disable_binary": false,
|
||||
"disable_status_size": true,
|
||||
"disable_preview": true,
|
||||
"disabled_capabilities": [
|
||||
"STATUS=SIZE",
|
||||
"PREVIEW"
|
||||
],
|
||||
"use_expunge_all_on_delete": false,
|
||||
"fast_simple_search": true,
|
||||
"force_select": false,
|
||||
|
|
|
|||
|
|
@ -30,15 +30,10 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
|
||||
private int $iTagCount = 0;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $aCapabilityItems = null;
|
||||
private ?array $aCapa = null;
|
||||
private ?array $aCapaRaw = null;
|
||||
|
||||
/**
|
||||
* @var FolderInformation
|
||||
*/
|
||||
private $oCurrentFolderInfo = null;
|
||||
private ?FolderInformation $oCurrentFolderInfo = null;
|
||||
|
||||
/**
|
||||
* Used by \MailSo\Mail\MailClient::MessageMimeStream
|
||||
|
|
@ -89,7 +84,8 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
if ($this->hasCapability('STARTTLS')) {
|
||||
$this->SendRequestGetResponse('STARTTLS');
|
||||
$this->EnableCrypto();
|
||||
$this->aCapabilityItems = null;
|
||||
$this->aCapa = null;
|
||||
$this->aCapaRaw = null;
|
||||
} else {
|
||||
$this->writeLogException(
|
||||
new \MailSo\Net\Exceptions\SocketUnsuppoterdSecureConnectionException('STARTTLS is not supported'),
|
||||
|
|
@ -281,13 +277,21 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
public function Capability() : ?array
|
||||
{
|
||||
if (!$this->aCapabilityItems) {
|
||||
if (!$this->aCapa) {
|
||||
$this->setCapabilities($this->SendRequestGetResponse('CAPABILITY'));
|
||||
}
|
||||
/*
|
||||
$this->aCapabilityItems[] = 'X-DOVECOT';
|
||||
$this->aCapa[] = 'X-DOVECOT';
|
||||
*/
|
||||
return $this->aCapabilityItems;
|
||||
return $this->aCapa;
|
||||
}
|
||||
|
||||
public function Capabilities() : ?array
|
||||
{
|
||||
if (!$this->aCapa) {
|
||||
$this->setCapabilities($this->SendRequestGetResponse('CAPABILITY'));
|
||||
}
|
||||
return $this->aCapaRaw;
|
||||
}
|
||||
|
||||
public function CapabilityValue(string $sExtentionName) : ?string
|
||||
|
|
@ -306,37 +310,17 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$aList = $oResponseCollection->getCapabilityResult();
|
||||
if ($aList) {
|
||||
if ($this->Settings->disable_metadata) {
|
||||
// Issue #365: Many folders on Cyrus IMAP breaks login
|
||||
$aList = \array_diff($aList, ['METADATA']);
|
||||
}
|
||||
if ($this->Settings->disable_move) {
|
||||
$aList = \array_diff($aList, ['MOVE']);
|
||||
}
|
||||
if ($this->Settings->disable_sort) {
|
||||
$aList = \array_diff($aList, ['SORT','ESORT']);
|
||||
}
|
||||
if ($this->Settings->disable_thread) {
|
||||
// Strip unused capabilities
|
||||
$aList = \array_diff($aList, ['PREVIEW=FUZZY', 'SNIPPET=FUZZY', 'SORT=DISPLAY']);
|
||||
// Set raw response capabilities
|
||||
$this->aCapaRaw = $aList;
|
||||
// Set active capabilities
|
||||
$aList = \array_diff($aList, $this->Settings->disabled_capabilities);
|
||||
if (\in_array('THREAD', $this->Settings->disabled_capabilities)) {
|
||||
$aList = \array_filter($aList, function ($item) { \str_starts_with($item, 'THREAD='); });
|
||||
}
|
||||
if ($this->Settings->disable_list_status) {
|
||||
$aList = \array_diff($aList, ['LIST-STATUS']);
|
||||
}
|
||||
if ($this->Settings->disable_binary) {
|
||||
$aList = \array_diff($aList, ['BINARY']);
|
||||
}
|
||||
if (8 > PHP_INT_SIZE) {
|
||||
$aList = \array_diff($aList, ['CONDSTORE']);
|
||||
$aList = \array_diff($aList, ['STATUS=SIZE']);
|
||||
}
|
||||
if ($this->Settings->disable_status_size) {
|
||||
$aList = \array_diff($aList, ['STATUS=SIZE']);
|
||||
}
|
||||
if ($this->Settings->disable_preview) {
|
||||
$aList = \array_diff($aList, ['PREVIEW']);
|
||||
}
|
||||
}
|
||||
$this->aCapabilityItems = $aList;
|
||||
$this->aCapa = $aList;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -19,46 +19,29 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
{
|
||||
public int
|
||||
$port = 143,
|
||||
$timeout = 300;
|
||||
$timeout = 300,
|
||||
$body_text_limit = 0,
|
||||
// $folder_list_limit = 200,
|
||||
$message_list_limit = 0,
|
||||
$thread_limit = 50;
|
||||
|
||||
public bool
|
||||
$disable_list_status = false,
|
||||
$disable_metadata = false,
|
||||
$disable_move = false,
|
||||
$disable_sort = false,
|
||||
$disable_thread = false,
|
||||
$disable_binary = false,
|
||||
// STATUS SIZE can take a significant amount of time, therefore not active by default
|
||||
$disable_status_size = true,
|
||||
// RFC 8970
|
||||
$disable_preview = true,
|
||||
$expunge_all_on_delete = false,
|
||||
$fast_simple_search = true,
|
||||
$fetch_new_messages = true,
|
||||
$force_select = false,
|
||||
$message_all_headers = false;
|
||||
|
||||
public int
|
||||
$body_text_limit = 0,
|
||||
// $folder_list_limit = 200,
|
||||
$message_list_limit = 0,
|
||||
$thread_limit = 50;
|
||||
|
||||
public string
|
||||
$search_filter = '';
|
||||
|
||||
public array
|
||||
$disabled_capabilities = [];
|
||||
|
||||
public static function fromArray(array $aSettings) : self
|
||||
{
|
||||
$object = parent::fromArray($aSettings);
|
||||
$options = [
|
||||
'disable_list_status',
|
||||
'disable_metadata',
|
||||
'disable_move',
|
||||
'disable_sort',
|
||||
'disable_thread',
|
||||
'disable_binary',
|
||||
'disable_status_size',
|
||||
'disable_preview',
|
||||
'expunge_all_on_delete',
|
||||
'fast_simple_search',
|
||||
'fetch_new_messages',
|
||||
|
|
@ -81,24 +64,56 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
$object->$option = \intval($aSettings[$option]);
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($aSettings['disabled_capabilities']) && \is_array($aSettings['disabled_capabilities'])) {
|
||||
$object->disabled_capabilities = $aSettings['disabled_capabilities'];
|
||||
}
|
||||
// Convert old disable_* settings
|
||||
if (!empty($aSettings['disable_list_status'])) {
|
||||
$object->disabled_capabilities[] = 'list-status';
|
||||
}
|
||||
if (!empty($aSettings['disable_metadata'])) {
|
||||
// Issue #365: Many folders on Cyrus IMAP breaks login
|
||||
$object->disabled_capabilities[] = 'METADATA';
|
||||
}
|
||||
if (!empty($aSettings['disable_move'])) {
|
||||
$object->disabled_capabilities[] = 'MOVE';
|
||||
}
|
||||
if (!empty($aSettings['disable_sort'])) {
|
||||
$object->disabled_capabilities[] = 'SORT';
|
||||
}
|
||||
if (!empty($aSettings['disable_thread'])) {
|
||||
$object->disabled_capabilities[] = 'THREAD';
|
||||
}
|
||||
if (!empty($aSettings['disable_binary'])) {
|
||||
$object->disabled_capabilities[] = 'BINARY';
|
||||
}
|
||||
if (!empty($aSettings['disable_status_size'])) {
|
||||
// STATUS SIZE can take a significant amount of time, therefore not active by default
|
||||
$object->disabled_capabilities[] = 'STATUS=SIZE';
|
||||
}
|
||||
if (!empty($aSettings['disable_preview'])) {
|
||||
// RFC 8970
|
||||
$object->disabled_capabilities[] = 'PREVIEW';
|
||||
}
|
||||
if (\in_array('SORT', $object->disabled_capabilities)) {
|
||||
$object->disabled_capabilities[] = 'ESORT';
|
||||
}
|
||||
$object->disabled_capabilities = \array_values(\array_unique($object->disabled_capabilities));
|
||||
|
||||
return $object;
|
||||
}
|
||||
|
||||
#[\ReturnTypeWillChange]
|
||||
public function jsonSerialize()
|
||||
{
|
||||
if (\in_array('SORT', $this->disabled_capabilities)) {
|
||||
$this->disabled_capabilities[] = 'ESORT';
|
||||
}
|
||||
return \array_merge(
|
||||
parent::jsonSerialize(),
|
||||
[
|
||||
// '@Object' => 'Object/ImapSettings',
|
||||
'disable_list_status' => $this->disable_list_status,
|
||||
'disable_metadata' => $this->disable_metadata,
|
||||
'disable_move' => $this->disable_move,
|
||||
'disable_sort' => $this->disable_sort,
|
||||
'disable_thread' => $this->disable_thread,
|
||||
'disable_binary' => $this->disable_binary,
|
||||
'disable_status_size' => $this->disable_status_size,
|
||||
'disable_preview' => $this->disable_preview,
|
||||
'use_expunge_all_on_delete' => $this->expunge_all_on_delete,
|
||||
// 'body_text_limit' => $this->body_text_limit,
|
||||
'fast_simple_search' => $this->fast_simple_search,
|
||||
|
|
@ -108,6 +123,7 @@ class Settings extends \MailSo\Net\ConnectSettings
|
|||
'message_list_limit' => $this->message_list_limit,
|
||||
'search_filter' => $this->search_filter,
|
||||
// 'thread_limit' => $this->thread_limit
|
||||
'disabled_capabilities' => \array_values(\array_unique($this->disabled_capabilities))
|
||||
]
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -808,7 +808,6 @@ class MailClient
|
|||
|
||||
public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus) : ?FolderCollection
|
||||
{
|
||||
// $this->oImapClient->Settings->disable_list_status
|
||||
$oFolderCollection = $this->oImapClient->FolderStatusList($sParent, $sListPattern);
|
||||
if (!$oFolderCollection->count()) {
|
||||
return null;
|
||||
|
|
|
|||
|
|
@ -97,14 +97,18 @@ trait AdminDomains
|
|||
$oSettings = $oDomain->ImapSettings();
|
||||
$oImapClient->Connect($oSettings);
|
||||
$mImapResult = [
|
||||
'connectCapa' => $oImapClient->Capability()
|
||||
'connectCapa' => $oImapClient->Capabilities()
|
||||
];
|
||||
|
||||
if (!empty($aAuth['user'])) {
|
||||
$oSettings->Login = $aAuth['user'];
|
||||
$oSettings->Password = $aAuth['pass'];
|
||||
$oImapClient->Login($oSettings);
|
||||
$mImapResult['authCapa'] = $oImapClient->Capability();
|
||||
$mImapResult['authCapa'] = \array_values(\array_unique(\array_map(function($n){
|
||||
return \str_starts_with($n, 'THREAD=') ? 'THREAD' : $n;
|
||||
},
|
||||
$oImapClient->Capabilities()
|
||||
)));
|
||||
}
|
||||
|
||||
$oImapClient->Disconnect();
|
||||
|
|
|
|||
|
|
@ -79,62 +79,18 @@
|
|||
}"></div>
|
||||
|
||||
<h4 data-i18n="POPUPS_DOMAIN/DISABLE_CAPABILITIES"></h4>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_list_status,
|
||||
label: 'LIST-STATUS'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_metadata,
|
||||
label: 'METADATA'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_move,
|
||||
label: 'MOVE'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_sort,
|
||||
label: 'SORT'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_thread,
|
||||
label: 'THREAD'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_binary,
|
||||
label: 'BINARY'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_status_size,
|
||||
label: 'STATUS SIZE'
|
||||
}
|
||||
}"></div>
|
||||
<div data-bind="component: {
|
||||
name: 'Checkbox',
|
||||
params: {
|
||||
value: imapDisable_preview,
|
||||
label: 'PREVIEW'
|
||||
}
|
||||
}"></div>
|
||||
|
||||
<div data-bind="foreach: imapCapabilities">
|
||||
<div style="display: inline-block; width: 33%; min-width: 16em">
|
||||
<label class="e-component e-checkbox material-design">
|
||||
<div>
|
||||
<input type="checkbox" data-bind="checked: $parent.imapDisabled_capabilities, value: $data"/>
|
||||
<div role="checkbox"></div>
|
||||
</div>
|
||||
<span data-bind="text: $data"></span>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<h4 data-i18n="POPUPS_DOMAIN/LIMITS"></h4>
|
||||
<div class="control-group">
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue