diff --git a/dev/Settings/User/Folders.js b/dev/Settings/User/Folders.js index ab16e5775..b3e06d9aa 100644 --- a/dev/Settings/User/Folders.js +++ b/dev/Settings/User/Folders.js @@ -67,7 +67,7 @@ export class UserSettingsFolders /*extends AbstractViewSettings*/ { Subscribe: folder.isSubscribed() ? 1 : 0 }) .then(data => { - folder.name(nameToEdit/*data.Name*/); + folder.name(nameToEdit/*data.name*/); if (folder.subFolders.length) { Remote.setTrigger(FolderUserStore.foldersLoading, true); // clearTimeout(Remote.foldersTimeout); diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/ACL.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/ACL.php index 86c80b3ac..ec4f46936 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/ACL.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/Commands/ACL.php @@ -24,7 +24,7 @@ trait ACL */ public function ACLAllow(string $sFolderName, string $command) : bool { - if ($this->IsSupported('ACL') || $this->IsSupported('RIGHTS=texk')) { + if ($this->IsSupported('ACL') || $this->CapabilityValue('RIGHTS')) { if ('MYRIGHTS' === $command) { return true; } @@ -128,6 +128,7 @@ trait ACL public function FolderMyRights(string $sFolderName) : ?ACLResponse { +// if ($this->ACLAllow($sFolderName, 'MYRIGHTS')) { // if ($this->IsSupported('ACL')) { $oResponses = $this->SendRequestGetResponse('MYRIGHTS', array($this->EscapeString($sFolderName))); foreach ($oResponses as $oResponse) { diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php index f4e5c8985..5d03b003e 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Imap/ImapClient.php @@ -280,6 +280,18 @@ class ImapClient extends \MailSo\Net\NetClient return $this->aCapabilityItems; } + public function CapabilityValue(string $sExtentionName) : ?string + { + $sExtentionName = \trim($sExtentionName) . '='; + $aCapabilities = $this->Capability() ?: []; + foreach ($aCapabilities as $string) { + if (\str_starts_with($string, $sExtentionName)) { + return \substr($string, \strlen($sExtentionName)); + } + } + return null; + } + private function setCapabilities(ResponseCollection $oResponseCollection) : void { $aList = $oResponseCollection->getCapabilityResult(); @@ -375,14 +387,8 @@ class ImapClient extends \MailSo\Net\NetClient */ public function AppendLimit() : ?int { - if ($this->Capability()) { - foreach ($this->aCapabilityItems as $string) { - if ('APPENDLIMIT=' === \substr($string, 0, 12)) { - return (int) \substr($string, 12); - } - } - } - return null; + $string = $this->CapabilityValue('APPENDLIMIT'); + return \is_null($string) ? null : (int) $string; } /** diff --git a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Folder.php b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Folder.php index fa6279307..a29af3361 100644 --- a/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Folder.php +++ b/snappymail/v/0.0.0/app/libraries/MailSo/Mail/Folder.php @@ -96,7 +96,7 @@ class Folder implements \JsonSerializable return $this->oImapFolder->IsInbox(); } - public function GetFolderListType() : int + public function GetType() : int { $aFlags = $this->oImapFolder->FlagsLowerCase(); // RFC 6154 @@ -205,10 +205,24 @@ class Folder implements \JsonSerializable // 'Hash' => $this->Hash($this->MailClient()->GenerateImapClientHash()) ); } +*/ +/* + $types = [ + FolderType::INBOX => 'inbox', + FolderType::ALL => 'all', + FolderType::ARCHIVE => 'archive', + FolderType::DRAFTS => 'drafts', + FolderType::FLAGGED => 'flagged', + FolderType::IMPORTANT => 'important', + FolderType::JUNK => 'junk', + FolderType::SENT => 'sent', + FolderType::TRASH => 'trash', + ]; + $type = $this->GetType(); */ return array( '@Object' => 'Object/Folder', - 'Name' => $this->Name(), + 'name' => $this->Name(), 'FullName' => $this->FullName(), 'Delimiter' => (string) $this->Delimiter(), 'isSubscribed' => $this->bSubscribed, @@ -219,10 +233,28 @@ class Folder implements \JsonSerializable // 'PermanentFlags' => $this->oImapFolder->PermanentFlags, 'Metadata' => $this->oImapFolder->Metadata(), 'UidNext' => $this->oImapFolder->UIDNEXT, - // RFC 8621 + // https://datatracker.ietf.org/doc/html/rfc8621#section-2 'totalEmails' => $this->oImapFolder->MESSAGES, 'unreadEmails' => $this->oImapFolder->UNSEEN, - 'id' => $this->oImapFolder->MAILBOXID + 'id' => $this->oImapFolder->MAILBOXID, +/* + 'role' => isset($types[$type]) ? $types[$type] : null, + + if ($this->IsSupported('ACL') || $this->CapabilityValue('RIGHTS')) { + $rights = $this->FolderMyRights($this->FullName()); + } + 'myRights' => [ + 'mayReadItems' => !$rights || ($rights->hasRight('l') && $rights->hasRight('r')), + 'mayAddItems' => !$rights || $rights->hasRight('i'), + 'mayRemoveItems' => !$rights || ($rights->hasRight('t') && $rights->hasRight('e')), + 'maySetSeen' => !$rights || $rights->hasRight('s'), + 'maySetKeywords' => !$rights || $rights->hasRight('w'), + 'mayCreateChild' => !$rights || $rights->hasRight('k'), + 'mayRename' => !$rights || $rights->hasRight('x'), + 'mayDelete' => !$rights || $rights->hasRight('x'), + 'maySubmit' => !$rights || $rights->hasRight('p') + ] +*/ ); } } 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 601b9f06f..2235175ea 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 @@ -481,7 +481,7 @@ trait Folders { foreach ($oFolders as $oFolder) { - $iFolderType = $oFolder->GetFolderListType(); + $iFolderType = $oFolder->GetType(); if (!isset($aResult[$iFolderType]) && \in_array($iFolderType, array( FolderType::INBOX, FolderType::SENT,