mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
FolderInformation() use jsonSerialize()
This commit is contained in:
parent
59b3fe70b6
commit
17b1deb95b
4 changed files with 40 additions and 54 deletions
|
|
@ -121,7 +121,7 @@ folderInformation = (folder, list) => {
|
|||
Remote.request('FolderInformation', (iError, data) => {
|
||||
if (!iError && data.Result) {
|
||||
const result = data.Result,
|
||||
folderFromCache = getFolderFromCacheList(result.folder);
|
||||
folderFromCache = getFolderFromCacheList(result.name);
|
||||
if (folderFromCache) {
|
||||
const oldHash = folderFromCache.etag,
|
||||
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
|
||||
|
|
@ -167,7 +167,6 @@ folderInformationMultiply = (boot = false) => {
|
|||
const utc = Date.now();
|
||||
oData.Result.forEach(item => {
|
||||
const folder = getFolderFromCacheList(item.name);
|
||||
|
||||
if (folder) {
|
||||
const oldHash = folder.etag,
|
||||
unreadCountChange = folder.unreadEmails() !== item.unreadEmails;
|
||||
|
|
|
|||
|
|
@ -50,8 +50,6 @@ class FolderInformation implements \JsonSerializable
|
|||
$result = array(
|
||||
'id' => $this->MAILBOXID,
|
||||
'name' => $this->FullName,
|
||||
'flags' => $this->Flags,
|
||||
'permanentFlags' => $this->PermanentFlags,
|
||||
'uidNext' => $this->UIDNEXT,
|
||||
'uidValidity' => $this->UIDVALIDITY
|
||||
);
|
||||
|
|
@ -71,6 +69,12 @@ class FolderInformation implements \JsonSerializable
|
|||
if ($this->etag) {
|
||||
$result['etag'] = $this->etag;
|
||||
}
|
||||
if ($this->Flags) {
|
||||
$result['flags'] = $this->Flags;
|
||||
}
|
||||
if ($this->PermanentFlags) {
|
||||
$result['permanentFlags'] = $this->PermanentFlags;
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -330,45 +330,38 @@ class MailClient
|
|||
*/
|
||||
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
|
||||
{
|
||||
$aFlags = array();
|
||||
if ($oRange && \count($oRange)) {
|
||||
// $oInfo = $this->oImapClient->FolderExamine($sFolderName);
|
||||
$oInfo = $this->oImapClient->FolderStatusAndSelect($sFolderName);
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||
FetchType::UID,
|
||||
FetchType::FLAGS
|
||||
), (string) $oRange, $oRange->UID);
|
||||
foreach ($aFetchResponse as $oFetchResponse) {
|
||||
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
||||
$aLowerFlags = \array_map('mb_strtolower', \array_map('\\MailSo\\Base\\Utils::Utf7ModifiedToUtf8', $oFetchResponse->GetFetchValue(FetchType::FLAGS)));
|
||||
$aFlags[] = array(
|
||||
'uid' => $iUid,
|
||||
'flags' => $aLowerFlags
|
||||
);
|
||||
if ($oRange) {
|
||||
// $aInfo = $this->oImapClient->FolderExamine($sFolderName)->jsonSerialize();
|
||||
$aInfo = $this->oImapClient->FolderStatusAndSelect($sFolderName)->jsonSerialize();
|
||||
$aInfo['messagesFlags'] = array();
|
||||
if (\count($oRange)) {
|
||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||
FetchType::UID,
|
||||
FetchType::FLAGS
|
||||
), (string) $oRange, $oRange->UID);
|
||||
foreach ($aFetchResponse as $oFetchResponse) {
|
||||
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
||||
$aLowerFlags = \array_map('mb_strtolower', \array_map('\\MailSo\\Base\\Utils::Utf7ModifiedToUtf8', $oFetchResponse->GetFetchValue(FetchType::FLAGS)));
|
||||
$aInfo['messagesFlags'][] = array(
|
||||
'uid' => $iUid,
|
||||
'flags' => $aLowerFlags
|
||||
);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
$oInfo = $this->oImapClient->FolderStatus($sFolderName);
|
||||
$aInfo = $this->oImapClient->FolderStatus($sFolderName)->jsonSerialize();
|
||||
}
|
||||
|
||||
return array(
|
||||
'folder' => $sFolderName,
|
||||
'totalEmails' => $oInfo->MESSAGES,
|
||||
'unreadEmails' => $oInfo->UNSEEN,
|
||||
'uidNext' => $oInfo->UIDNEXT,
|
||||
'uidValidity' => $oInfo->UIDVALIDITY,
|
||||
'highestModSeq' => $oInfo->HIGHESTMODSEQ,
|
||||
'appendLimit' => $oInfo->APPENDLIMIT ?: $this->oImapClient->AppendLimit(),
|
||||
'mailboxId' => $oInfo->MAILBOXID ?: '',
|
||||
// 'flags' => $oInfo->Flags,
|
||||
// 'permanentFlags' => $oInfo->PermanentFlags,
|
||||
'etag' => $oInfo->etag,
|
||||
'messagesFlags' => $aFlags,
|
||||
'newMessages' => $this->getFolderNextMessageInformation(
|
||||
if ($iPrevUidNext) {
|
||||
$aInfo['newMessages'] = $this->getFolderNextMessageInformation(
|
||||
$sFolderName,
|
||||
$iPrevUidNext,
|
||||
\intval($oInfo->UIDNEXT)
|
||||
)
|
||||
);
|
||||
\intval($aInfo['uidNext'])
|
||||
);
|
||||
}
|
||||
|
||||
// $aInfo['appendLimit'] = $aInfo['appendLimit'] ?: $this->oImapClient->AppendLimit();
|
||||
return $aInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -302,23 +302,13 @@ trait Folders
|
|||
|
||||
$aFolders = \array_unique($aFolders);
|
||||
foreach ($aFolders as $sFolder) {
|
||||
if (\strlen($sFolder) && 'INBOX' !== \strtoupper($sFolder)) {
|
||||
try
|
||||
{
|
||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder);
|
||||
if (isset($aInboxInformation['folder'])) {
|
||||
$aResult[] = [
|
||||
'name' => $aInboxInformation['folder'],
|
||||
'etag' => $aInboxInformation['etag'],
|
||||
'totalEmails' => $aInboxInformation['totalEmails'],
|
||||
'unreadEmails' => $aInboxInformation['unreadEmails'],
|
||||
];
|
||||
}
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$this->Logger()->WriteException($oException);
|
||||
}
|
||||
try
|
||||
{
|
||||
$aResult[] = $this->MailClient()->FolderInformation($sFolder);
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
$this->Logger()->WriteException($oException);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue