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) => {
|
Remote.request('FolderInformation', (iError, data) => {
|
||||||
if (!iError && data.Result) {
|
if (!iError && data.Result) {
|
||||||
const result = data.Result,
|
const result = data.Result,
|
||||||
folderFromCache = getFolderFromCacheList(result.folder);
|
folderFromCache = getFolderFromCacheList(result.name);
|
||||||
if (folderFromCache) {
|
if (folderFromCache) {
|
||||||
const oldHash = folderFromCache.etag,
|
const oldHash = folderFromCache.etag,
|
||||||
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
|
unreadCountChange = (folderFromCache.unreadEmails() !== result.unreadEmails);
|
||||||
|
|
@ -167,7 +167,6 @@ folderInformationMultiply = (boot = false) => {
|
||||||
const utc = Date.now();
|
const utc = Date.now();
|
||||||
oData.Result.forEach(item => {
|
oData.Result.forEach(item => {
|
||||||
const folder = getFolderFromCacheList(item.name);
|
const folder = getFolderFromCacheList(item.name);
|
||||||
|
|
||||||
if (folder) {
|
if (folder) {
|
||||||
const oldHash = folder.etag,
|
const oldHash = folder.etag,
|
||||||
unreadCountChange = folder.unreadEmails() !== item.unreadEmails;
|
unreadCountChange = folder.unreadEmails() !== item.unreadEmails;
|
||||||
|
|
|
||||||
|
|
@ -50,8 +50,6 @@ class FolderInformation implements \JsonSerializable
|
||||||
$result = array(
|
$result = array(
|
||||||
'id' => $this->MAILBOXID,
|
'id' => $this->MAILBOXID,
|
||||||
'name' => $this->FullName,
|
'name' => $this->FullName,
|
||||||
'flags' => $this->Flags,
|
|
||||||
'permanentFlags' => $this->PermanentFlags,
|
|
||||||
'uidNext' => $this->UIDNEXT,
|
'uidNext' => $this->UIDNEXT,
|
||||||
'uidValidity' => $this->UIDVALIDITY
|
'uidValidity' => $this->UIDVALIDITY
|
||||||
);
|
);
|
||||||
|
|
@ -71,6 +69,12 @@ class FolderInformation implements \JsonSerializable
|
||||||
if ($this->etag) {
|
if ($this->etag) {
|
||||||
$result['etag'] = $this->etag;
|
$result['etag'] = $this->etag;
|
||||||
}
|
}
|
||||||
|
if ($this->Flags) {
|
||||||
|
$result['flags'] = $this->Flags;
|
||||||
|
}
|
||||||
|
if ($this->PermanentFlags) {
|
||||||
|
$result['permanentFlags'] = $this->PermanentFlags;
|
||||||
|
}
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -330,45 +330,38 @@ class MailClient
|
||||||
*/
|
*/
|
||||||
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
|
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, SequenceSet $oRange = null) : array
|
||||||
{
|
{
|
||||||
$aFlags = array();
|
if ($oRange) {
|
||||||
if ($oRange && \count($oRange)) {
|
// $aInfo = $this->oImapClient->FolderExamine($sFolderName)->jsonSerialize();
|
||||||
// $oInfo = $this->oImapClient->FolderExamine($sFolderName);
|
$aInfo = $this->oImapClient->FolderStatusAndSelect($sFolderName)->jsonSerialize();
|
||||||
$oInfo = $this->oImapClient->FolderStatusAndSelect($sFolderName);
|
$aInfo['messagesFlags'] = array();
|
||||||
$aFetchResponse = $this->oImapClient->Fetch(array(
|
if (\count($oRange)) {
|
||||||
FetchType::UID,
|
$aFetchResponse = $this->oImapClient->Fetch(array(
|
||||||
FetchType::FLAGS
|
FetchType::UID,
|
||||||
), (string) $oRange, $oRange->UID);
|
FetchType::FLAGS
|
||||||
foreach ($aFetchResponse as $oFetchResponse) {
|
), (string) $oRange, $oRange->UID);
|
||||||
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
foreach ($aFetchResponse as $oFetchResponse) {
|
||||||
$aLowerFlags = \array_map('mb_strtolower', \array_map('\\MailSo\\Base\\Utils::Utf7ModifiedToUtf8', $oFetchResponse->GetFetchValue(FetchType::FLAGS)));
|
$iUid = (int) $oFetchResponse->GetFetchValue(FetchType::UID);
|
||||||
$aFlags[] = array(
|
$aLowerFlags = \array_map('mb_strtolower', \array_map('\\MailSo\\Base\\Utils::Utf7ModifiedToUtf8', $oFetchResponse->GetFetchValue(FetchType::FLAGS)));
|
||||||
'uid' => $iUid,
|
$aInfo['messagesFlags'][] = array(
|
||||||
'flags' => $aLowerFlags
|
'uid' => $iUid,
|
||||||
);
|
'flags' => $aLowerFlags
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
$oInfo = $this->oImapClient->FolderStatus($sFolderName);
|
$aInfo = $this->oImapClient->FolderStatus($sFolderName)->jsonSerialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
return array(
|
if ($iPrevUidNext) {
|
||||||
'folder' => $sFolderName,
|
$aInfo['newMessages'] = $this->getFolderNextMessageInformation(
|
||||||
'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(
|
|
||||||
$sFolderName,
|
$sFolderName,
|
||||||
$iPrevUidNext,
|
$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);
|
$aFolders = \array_unique($aFolders);
|
||||||
foreach ($aFolders as $sFolder) {
|
foreach ($aFolders as $sFolder) {
|
||||||
if (\strlen($sFolder) && 'INBOX' !== \strtoupper($sFolder)) {
|
try
|
||||||
try
|
{
|
||||||
{
|
$aResult[] = $this->MailClient()->FolderInformation($sFolder);
|
||||||
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder);
|
}
|
||||||
if (isset($aInboxInformation['folder'])) {
|
catch (\Throwable $oException)
|
||||||
$aResult[] = [
|
{
|
||||||
'name' => $aInboxInformation['folder'],
|
$this->Logger()->WriteException($oException);
|
||||||
'etag' => $aInboxInformation['etag'],
|
|
||||||
'totalEmails' => $aInboxInformation['totalEmails'],
|
|
||||||
'unreadEmails' => $aInboxInformation['unreadEmails'],
|
|
||||||
];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (\Throwable $oException)
|
|
||||||
{
|
|
||||||
$this->Logger()->WriteException($oException);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue