IMAP UID is integer

This commit is contained in:
djmaze 2021-09-10 16:28:29 +02:00
parent 9ffc90946c
commit 96e2e6576c
20 changed files with 124 additions and 139 deletions

View file

@ -121,18 +121,17 @@ export const
* @param {string} folder
* @param {number=} page = 1
* @param {string=} search = ''
* @param {string=} threadUid = ''
* @param {number=} threadUid = 0
* @returns {string}
*/
mailBox = (folder, page = 1, search = '', threadUid = '') => {
mailBox = (folder, page = 1, search = '', threadUid = 0) => {
page = pInt(page, 1);
search = pString(search);
let result = HASH_PREFIX + 'mailbox/';
if (folder) {
const resultThreadUid = pInt(threadUid);
result += encodeURI(folder) + (0 < resultThreadUid ? '~' + resultThreadUid : '');
result += encodeURI(folder) + (threadUid ? '~' + threadUid : '');
}
if (1 < page) {

View file

@ -96,7 +96,7 @@ export class MessageModel extends AbstractModel {
_reset() {
this.folder = '';
this.uid = '';
this.uid = 0;
this.hash = '';
this.requestHash = '';
this.externalProxy = false;
@ -188,9 +188,8 @@ export class MessageModel extends AbstractModel {
* @returns {boolean}
*/
revivePropertiesFromJson(json) {
if ('Priority' in json) {
let p = parseInt(json.Priority, 10);
json.Priority = MessagePriority.High == p || MessagePriority.Low == p ? p : MessagePriority.Normal;
if ('Priority' in json && ![MessagePriority.High, MessagePriority.Low].includes(json.Priority)) {
json.Priority = MessagePriority.Normal;
}
if (super.revivePropertiesFromJson(json)) {
// this.foundedCIDs = isArray(json.FoundedCIDs) ? json.FoundedCIDs : [];

View file

@ -239,7 +239,7 @@ class RemoteUserFetch extends AbstractFetchRemote {
inboxUidNext = getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : '';
params.Folder = sFolderFullNameRaw;
params.ThreadUid = useThreads ? params.ThreadUid : '';
params.ThreadUid = useThreads ? params.ThreadUid : 0;
params = Object.assign({
Folder: '',
Offset: 0,
@ -247,7 +247,7 @@ class RemoteUserFetch extends AbstractFetchRemote {
Search: '',
UidNext: inboxUidNext,
UseThreads: useThreads,
ThreadUid: '',
ThreadUid: 0,
Sort: FolderUserStore.sortMode()
}, params);
@ -385,8 +385,8 @@ class RemoteUserFetch extends AbstractFetchRemote {
if (request) {
this.defaultRequest(fCallback, 'FolderInformation', {
Folder: folder,
FlagsUids: isArray(uids) ? uids.join(',') : '',
UidNext: getFolderInboxName() === folder ? getFolderUidNext(folder) : ''
FlagsUids: isArray(uids) ? uids : [],
UidNext: getFolderInboxName() === folder ? getFolderUidNext(folder) : 0
});
} else if (SettingsUserStore.useThreads()) {
rl.app.reloadFlagsCurrentMessageListAndMessageFromCache();
@ -463,15 +463,15 @@ class RemoteUserFetch extends AbstractFetchRemote {
/**
* @param {?Function} fCallback
* @param {string} sMessageFolder
* @param {string} sMessageUid
* @param {number} iMessageUid
* @param {string} sReadReceipt
* @param {string} sSubject
* @param {string} sText
*/
sendReadReceiptMessage(fCallback, sMessageFolder, sMessageUid, sReadReceipt, sSubject, sText) {
sendReadReceiptMessage(fCallback, sMessageFolder, iMessageUid, sReadReceipt, sSubject, sText) {
this.defaultRequest(fCallback, 'SendReadReceiptMessage', {
MessageFolder: sMessageFolder,
MessageUid: sMessageUid,
MessageUid: iMessageUid,
ReadReceipt: sReadReceipt,
Subject: sSubject,
Text: sText

View file

@ -63,16 +63,13 @@ export class MailBoxUserScreen extends AbstractScreen {
onRoute(folderHash, page, search) {
const folder = getFolderFromCacheList(getFolderFullNameRaw(folderHash.replace(/~([\d]+)$/, '')));
if (folder) {
let threadUid = folderHash.replace(/^.+~([\d]+)$/, '$1');
if (folderHash === threadUid) {
threadUid = '';
}
let threadUid = folderHash.replace(/^.+~(\d+)$/, '$1');
FolderUserStore.currentFolder(folder);
MessageUserStore.listPage(1 > page ? 1 : page);
MessageUserStore.listSearch(search);
MessageUserStore.listThreadUid(threadUid);
MessageUserStore.listThreadUid((folderHash === threadUid) ? 0 : pInt(threadUid));
rl.app.reloadMessageList();
}

View file

@ -77,14 +77,14 @@ export const MessageUserStore = new class {
addObservablesTo(this, {
listCount: 0,
listSearch: '',
listThreadUid: '',
listThreadUid: 0,
listPage: 1,
listPageBeforeThread: 1,
listError: '',
listEndFolder: '',
listEndSearch: '',
listEndThreadUid: '',
listEndThreadUid: 0,
listEndPage: 1,
listLoading: false,
@ -348,11 +348,11 @@ export const MessageUserStore = new class {
if (this.listThreadUid()) {
if (
messageList.length &&
!!messageList.find(item => !!(item && item.deleted() && item.uid === this.listThreadUid()))
!!messageList.find(item => !!(item && item.deleted() && item.uid == this.listThreadUid()))
) {
const message = messageList.find(item => item && !item.deleted());
if (message && this.listThreadUid() !== pString(message.uid)) {
this.listThreadUid(pString(message.uid));
if (message && this.listThreadUid() != message.uid) {
this.listThreadUid(message.uid);
rl.route.setHash(
mailBox(
@ -379,7 +379,7 @@ export const MessageUserStore = new class {
true
);
} else {
this.listThreadUid('');
this.listThreadUid(0);
rl.route.setHash(
mailBox(
@ -437,7 +437,7 @@ export const MessageUserStore = new class {
message.folder === json.Folder
) {
const threads = message.threads();
if (message.uid !== json.Uid && 1 < threads.length && threads.includes(json.Uid)) {
if (message.uid != json.Uid && 1 < threads.length && threads.includes(json.Uid)) {
message = oMessage ? null : MessageModel.reviveFromJson(json);
if (message) {
message.threads(threads);
@ -450,7 +450,7 @@ export const MessageUserStore = new class {
}
}
if (message && message.uid === json.Uid) {
if (message && message.uid == json.Uid) {
oMessage || this.messageError('');
if (cached) {
@ -565,7 +565,7 @@ export const MessageUserStore = new class {
if (
selectedMessage &&
message &&
(message.folder !== selectedMessage.folder || message.uid !== selectedMessage.uid)
(message.folder !== selectedMessage.folder || message.uid != selectedMessage.uid)
) {
this.selectorMessageSelected(null);
if (1 === this.list.length) {
@ -576,7 +576,7 @@ export const MessageUserStore = new class {
subMessage =>
subMessage &&
subMessage.folder === message.folder &&
subMessage.uid === message.uid
subMessage.uid == message.uid
);
if (selectedMessage) {
@ -598,11 +598,11 @@ export const MessageUserStore = new class {
}
}
selectMessageByFolderAndUid(sFolder, sUid) {
if (sFolder && sUid) {
selectMessageByFolderAndUid(sFolder, iUid) {
if (sFolder && iUid) {
this.message(this.staticMessage.populateByMessageListItem(null));
this.message().folder = sFolder;
this.message().uid = sUid;
this.message().uid = iUid;
this.populateMessageBody(this.message());
} else {
@ -671,7 +671,7 @@ export const MessageUserStore = new class {
this.listCount(iCount);
this.listSearch(pString(collection.Search));
this.listPage(Math.ceil(iOffset / SettingsUserStore.messagesPerPage() + 1));
this.listThreadUid(pString(data.Result.ThreadUid));
this.listThreadUid(data.Result.ThreadUid);
this.listEndFolder(collection.Folder);
this.listEndSearch(this.listSearch());

View file

@ -170,7 +170,7 @@ class ComposePopupView extends AbstractViewPopup {
showReplyTo: false,
draftFolder: '',
draftUid: '',
draftUid: 0,
sending: false,
saving: false,
@ -465,7 +465,7 @@ class ComposePopupView extends AbstractViewPopup {
if (this.bFromDraft) {
const message = MessageUserStore.message();
if (message && this.draftFolder() === message.folder && this.draftUid() === message.uid) {
if (message && this.draftFolder() === message.folder && this.draftUid() == message.uid) {
MessageUserStore.message(null);
}
}
@ -1449,7 +1449,7 @@ class ComposePopupView extends AbstractViewPopup {
this.dragAndDropVisible(false);
this.draftFolder('');
this.draftUid('');
this.draftUid(0);
this.sending(false);
this.saving(false);

View file

@ -216,10 +216,10 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
);
addEventListener('mailbox.message.show', e => {
const sFolder = e.detail.Folder, sUid = e.detail.Uid;
const sFolder = e.detail.Folder, iUid = e.detail.Uid;
const message = MessageUserStore.list.find(
item => item && sFolder === item.folder && sUid === item.uid
item => item && sFolder === item.folder && iUid == item.uid
);
if ('INBOX' === sFolder) {
@ -233,7 +233,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
rl.route.setHash(mailBox(sFolder, 1));
}
MessageUserStore.selectMessageByFolderAndUid(sFolder, sUid);
MessageUserStore.selectMessageByFolderAndUid(sFolder, iUid);
}
});
@ -473,10 +473,10 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
/**
* @param {string} sFolderFullNameRaw
* @param {number} iSetAction
* @param {string} sThreadUid = ''
* @param {number} iThreadUid = ''
* @returns {void}
*/
setActionForAll(sFolderFullNameRaw, iSetAction, sThreadUid = '') {
setActionForAll(sFolderFullNameRaw, iSetAction, iThreadUid = 0) {
if (sFolderFullNameRaw) {
let cnt = 0;
const uids = [];
@ -496,7 +496,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
uids.push(message.uid);
});
if (sThreadUid) {
if (iThreadUid) {
folder.messageCountUnread(folder.messageCountUnread() - cnt);
if (0 > folder.messageCountUnread()) {
folder.messageCountUnread(0);
@ -508,7 +508,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
MessageFlagsCache.clearFolder(sFolderFullNameRaw);
}
Remote.messageSetSeenToAll(()=>0, sFolderFullNameRaw, true, sThreadUid ? uids : null);
Remote.messageSetSeenToAll(()=>0, sFolderFullNameRaw, true, iThreadUid ? uids : null);
break;
case MessageSetAction.UnsetSeen:
folder = getFolderFromCacheList(sFolderFullNameRaw);
@ -522,7 +522,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
uids.push(message.uid);
});
if (sThreadUid) {
if (iThreadUid) {
folder.messageCountUnread(folder.messageCountUnread() + cnt);
if (folder.messageCountAll() < folder.messageCountUnread()) {
folder.messageCountUnread(folder.messageCountAll());
@ -534,7 +534,7 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
MessageFlagsCache.clearFolder(sFolderFullNameRaw);
}
Remote.messageSetSeenToAll(()=>0, sFolderFullNameRaw, false, sThreadUid ? uids : null);
Remote.messageSetSeenToAll(()=>0, sFolderFullNameRaw, false, iThreadUid ? uids : null);
break;
// no default
}
@ -702,15 +702,15 @@ export class MessageListMailBoxUserView extends AbstractViewRight {
eqs(event, '.checkboxCheckAll') && this.checkAll(!this.checkAll());
el = eqs(event, '.messageListItem .flagParent');
el = eqs(event, '.flagParent');
el && this.flagMessages(ko.dataFor(el));
el = eqs(event, '.messageListItem .threads-len');
el = eqs(event, '.threads-len');
el && this.gotoThread(ko.dataFor(el));
});
dom.addEventListener('dblclick', event => {
let el = eqs(event, '.messageListItem .actionHandle');
let el = eqs(event, '.actionHandle');
el && this.gotoThread(ko.dataFor(el));
});

View file

@ -60,7 +60,9 @@ class FolderInformation
public $Unread = null;
/**
* @var string
* rfc3501 2.3.1.1
* A 32-bit value
* @var int
*/
public $Uidnext = null;

View file

@ -315,7 +315,7 @@ class ResponseCollection extends \MailSo\Base\Collection
}
else if ('UIDNEXT' === $oResponse->OptionalResponse[0])
{
$oResult->Uidnext = $oResponse->OptionalResponse[1];
$oResult->Uidnext = (int) $oResponse->OptionalResponse[1];
}
else if ('HIGHESTMODSEQ' === $oResponse->OptionalResponse[0])
{

View file

@ -560,7 +560,7 @@ class MailClient
}
protected function initFolderValues(string $sFolderName, int &$iCount, int &$iUnseenCount,
string &$sUidNext, int &$iHighestModSeq = 0) : void
int &$iUidNext, int &$iHighestModSeq = 0) : void
{
$aTypes = array(
\MailSo\Imap\Enumerations\FolderResponseStatus::MESSAGES,
@ -579,7 +579,7 @@ class MailClient
$iUnseenCount = (int) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::UNSEEN] ?? 0;
$sUidNext = (string) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::UIDNEXT] ?? '0';
$iUidNext = (int) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::UIDNEXT] ?? 0;
$iHighestModSeq = (int) $aFolderStatus[\MailSo\Imap\Enumerations\FolderResponseStatus::HIGHESTMODSEQ] ?? 0;
}
@ -593,20 +593,20 @@ class MailClient
);
}
public function GenerateFolderHash(string $sFolder, int $iCount, int $iUnseenCount, string $sUidNext, int $iHighestModSeq = 0) : string
public function GenerateFolderHash(string $sFolder, int $iCount, int $iUnseenCount, int $iUidNext, int $iHighestModSeq = 0) : string
{
$iUnseenCount = 0; // unneccessery
return \md5('FolderHash/'.$sFolder.'-'.$iCount.'-'.$iUnseenCount.'-'.$sUidNext.'-'.
return \md5('FolderHash/'.$sFolder.'-'.$iCount.'-'.$iUnseenCount.'-'.$iUidNext.'-'.
$iHighestModSeq.'-'.$this->GenerateImapClientHash().'-'.
\MailSo\Config::$MessageListPermanentFilter
);
}
private function getFolderNextMessageInformation(string $sFolderName, string $sPrevUidNext, string $sCurrentUidNext) : array
private function getFolderNextMessageInformation(string $sFolderName, int $iPrevUidNext, int $iCurrentUidNext) : array
{
$aNewMessages = array();
if (\strlen($sPrevUidNext) && (string) $sPrevUidNext !== (string) $sCurrentUidNext)
if ($iPrevUidNext && $iPrevUidNext != $iCurrentUidNext)
{
$this->oImapClient->FolderSelect($sFolderName);
@ -619,7 +619,7 @@ class MailClient
\MailSo\Mime\Enumerations\Header::SUBJECT,
\MailSo\Mime\Enumerations\Header::CONTENT_TYPE
))
), $sPrevUidNext.':*', true);
), $iPrevUidNext.':*', true);
foreach ($aFetchResponse as /* @var $oFetchResponse \MailSo\Imap\FetchResponse */ $oFetchResponse)
{
@ -628,7 +628,7 @@ class MailClient
if (!\in_array(\strtolower(\MailSo\Imap\Enumerations\MessageFlag::SEEN), $aFlags))
{
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$iUid = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$sHeaders = $oFetchResponse->GetHeaderFieldsValue();
$oHeaders = new \MailSo\Mime\HeaderCollection($sHeaders);
@ -651,7 +651,7 @@ class MailClient
$aNewMessages[] = array(
'Folder' => $sFolderName,
'Uid' => $sUid,
'Uid' => $iUid,
'Subject' => $oHeaders->ValueByName(\MailSo\Mime\Enumerations\Header::SUBJECT, !\strlen($sCharset)),
'From' => $oHeaders->GetAsEmailCollection(\MailSo\Mime\Enumerations\Header::FROM_, !\strlen($sCharset))
);
@ -667,7 +667,7 @@ class MailClient
* @throws \MailSo\Net\Exceptions\Exception
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function FolderInformation(string $sFolderName, string $sPrevUidNext = '', array $aUids = array()) : array
public function FolderInformation(string $sFolderName, int $iPrevUidNext = 0, array $aUids = array()) : array
{
$aFlags = array();
@ -688,29 +688,29 @@ class MailClient
foreach ($aFetchResponse as $oFetchResponse)
{
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$aFlags[(\is_numeric($sUid) ? (int) $sUid : 0)] =
$iUid = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$aFlags[$iUid] =
$oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
}
}
$iCount = 0;
$iUnseenCount = 0;
$sUidNext = '0';
$iUidNext = 0;
$iHighestModSeq = 0;
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext, $iHighestModSeq);
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $iUidNext, $iHighestModSeq);
$aResult = array(
'Folder' => $sFolderName,
'Hash' => $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $sUidNext, $iHighestModSeq),
'Hash' => $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $iUidNext, $iHighestModSeq),
'MessageCount' => $iCount,
'MessageUnseenCount' => $iUnseenCount,
'UidNext' => (int) $sUidNext,
'UidNext' => $iUidNext,
'Flags' => $aFlags,
'HighestModSeq' => $iHighestModSeq,
'NewMessages' => 'INBOX' === $sFolderName && \MailSo\Config::$CheckNewMessages ?
$this->getFolderNextMessageInformation($sFolderName, $sPrevUidNext, $sUidNext) : array()
$this->getFolderNextMessageInformation($sFolderName, $iPrevUidNext, $iUidNext) : array()
);
return $aResult;
@ -725,12 +725,12 @@ class MailClient
{
$iCount = 0;
$iUnseenCount = 0;
$sUidNext = '0';
$iUidNext = 0;
$iHighestModSeq = 0;
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $sUidNext, $iHighestModSeq);
$this->initFolderValues($sFolderName, $iCount, $iUnseenCount, $iUidNext, $iHighestModSeq);
return $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $sUidNext, $iHighestModSeq);
return $this->GenerateFolderHash($sFolderName, $iCount, $iUnseenCount, $iUidNext, $iHighestModSeq);
}
/**
@ -1567,9 +1567,9 @@ class MailClient
* @throws \MailSo\Imap\Exceptions\Exception
*/
public function MessageList(string $sFolderName, int $iOffset = 0, int $iLimit = 10,
string $sSearch = '', string $sPrevUidNext = '', ?\MailSo\Cache\CacheClient $oCacher = null,
string $sSearch = '', int $iPrevUidNext = 0, ?\MailSo\Cache\CacheClient $oCacher = null,
bool $bUseSortIfSupported = false, bool $bUseThreadSortIfSupported = false,
string $sThreadUid = '', string $sFilter = '', string $sSort = '') : MessageCollection
int $iThreadUid = 0, string $sFilter = '', string $sSort = '') : MessageCollection
{
$sFilter = \trim($sFilter);
$sSearch = \trim($sSearch);
@ -1588,18 +1588,16 @@ class MailClient
$oMessageCollection->Offset = $iOffset;
$oMessageCollection->Limit = $iLimit;
$oMessageCollection->Search = $sSearch;
$oMessageCollection->ThreadUid = $sThreadUid;
$oMessageCollection->ThreadUid = $iThreadUid;
$oMessageCollection->Filtered = '' !== \MailSo\Config::$MessageListPermanentFilter;
$aUids = array();
$mAllSortedUids = null;
$mAllThreads = null;
$iThreadUid = empty($sThreadUid) ? 0 : (int) $sThreadUid;
$iMessageRealCount = 0;
$iMessageUnseenCount = 0;
$sUidNext = '0';
$iUidNext = 0;
$iHighestModSeq = 0;
$bUseSortIfSupported = $bUseSortIfSupported && $this->oImapClient->IsSupported('SORT');
@ -1607,7 +1605,7 @@ class MailClient
$bUseThreadSortIfSupported = $bUseThreadSortIfSupported ?
($this->oImapClient->IsSupported('THREAD=REFS') || $this->oImapClient->IsSupported('THREAD=REFERENCES') || $this->oImapClient->IsSupported('THREAD=ORDEREDSUBJECT')) : false;
if (!empty($sThreadUid) && !$bUseThreadSortIfSupported)
if ($iThreadUid && !$bUseThreadSortIfSupported)
{
throw new \MailSo\Base\Exceptions\InvalidArgumentException;
}
@ -1617,7 +1615,7 @@ class MailClient
$oCacher = null;
}
$this->initFolderValues($sFolderName, $iMessageRealCount, $iMessageUnseenCount, $sUidNext, $iHighestModSeq);
$this->initFolderValues($sFolderName, $iMessageRealCount, $iMessageUnseenCount, $iUidNext, $iHighestModSeq);
if ($bUseFilter)
{
@ -1625,14 +1623,14 @@ class MailClient
}
$oMessageCollection->FolderHash = $this->GenerateFolderHash(
$sFolderName, $iMessageRealCount, $iMessageUnseenCount, $sUidNext, $iHighestModSeq);
$sFolderName, $iMessageRealCount, $iMessageUnseenCount, $iUidNext, $iHighestModSeq);
$oMessageCollection->UidNext = $sUidNext;
$oMessageCollection->UidNext = $iUidNext;
if (empty($sThreadUid) && \strlen($sPrevUidNext) && 'INBOX' === $sFolderName)
if (!$iThreadUid && $iPrevUidNext && 'INBOX' === $sFolderName)
{
$oMessageCollection->NewMessages = $this->getFolderNextMessageInformation(
$sFolderName, $sPrevUidNext, $sUidNext);
$sFolderName, $iPrevUidNext, $iUidNext);
}
$bSearch = false;
@ -1711,7 +1709,7 @@ class MailClient
{
$aNewUids[] = $iUid;
}
else if ($bUseThreadSortIfSupported && 0 === $iThreadUid && isset($mAllThreads[$iUid]) && \is_array($mAllThreads[$iUid]))
else if ($bUseThreadSortIfSupported && !$iThreadUid && isset($mAllThreads[$iUid]) && \is_array($mAllThreads[$iUid]))
{
foreach ($mAllThreads[$iUid] as $iSubUid)
{

View file

@ -311,14 +311,12 @@ class Message implements \JsonSerializable
$oBodyStructure = $oFetchResponse->GetFetchBodyStructure();
}
$sUid = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$sSize = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
$sInternalDate = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::INTERNALDATE);
$aFlags = $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::FLAGS);
$this->sFolder = $sFolder;
$this->iUid = \is_numeric($sUid) ? (int) $sUid : 0;
$this->iSize = \is_numeric($sSize) ? (int) $sSize : 0;
$this->iUid = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::UID);
$this->iSize = (int) $oFetchResponse->GetFetchValue(\MailSo\Imap\Enumerations\FetchType::RFC822_SIZE);
$this->aFlags = \is_array($aFlags) ? $aFlags : array();
$this->aFlagsLowerCase = \array_map('strtolower', $this->aFlags);
@ -497,7 +495,7 @@ class Message implements \JsonSerializable
if (0 < \strlen($sDraftInfo)) {
$sType = '';
$sFolder = '';
$sUid = '';
$iUid = 0;
$oParameters = new \MailSo\Mime\ParameterCollection($sDraftInfo);
foreach ($oParameters as $oParameter) {
@ -507,7 +505,7 @@ class Message implements \JsonSerializable
$sType = $oParameter->Value();
break;
case 'uid':
$sUid = $oParameter->Value();
$iUid = (int) $oParameter->Value();
break;
case 'folder':
$sFolder = \base64_decode($oParameter->Value());
@ -515,8 +513,8 @@ class Message implements \JsonSerializable
}
}
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && 0 < \strlen($sUid)) {
$this->aDraftInfo = array($sType, $sUid, $sFolder);
if (0 < \strlen($sType) && 0 < \strlen($sFolder) && $iUid) {
$this->aDraftInfo = array($sType, $iUid, $sFolder);
}
}
}
@ -661,7 +659,7 @@ class Message implements \JsonSerializable
return array(
'@Object' => 'Object/Message',
'Folder' => $this->sFolder,
'Uid' => (string) $this->iUid,
'Uid' => $this->iUid,
'Subject' => \trim(\MailSo\Base\Utils::Utf8Clear($this->sSubject)),
'MessageId' => $this->sMessageId,
'Size' => $this->iSize,

View file

@ -58,12 +58,12 @@ class MessageCollection extends \MailSo\Base\Collection
public $Search;
/**
* @var string
* @var int
*/
public $UidNext;
/**
* @var string
* @var int
*/
public $ThreadUid;
@ -104,8 +104,8 @@ class MessageCollection extends \MailSo\Base\Collection
$this->Offset = 0;
$this->Limit = 0;
$this->Search = '';
$this->UidNext = '';
$this->ThreadUid = '';
$this->UidNext = 0;
$this->ThreadUid = 0;
$this->NewMessages = array();
$this->Filtered = false;

View file

@ -308,12 +308,12 @@ class Message
return $this;
}
public function SetDraftInfo(string $sType, string $sUid, string $sFolder) : self
public function SetDraftInfo(string $sType, int $iUid, string $sFolder) : self
{
$this->aHeadersValue[Enumerations\Header::X_DRAFT_INFO] = (new ParameterCollection)
->Add(new Parameter('type', $sType))
->Add(new Parameter('uid', $sUid))
->Add(new Parameter('folder', base64_encode($sFolder)))
->Add(new Parameter('uid', $iUid))
->Add(new Parameter('folder', \base64_encode($sFolder)))
;
return $this;

View file

@ -336,16 +336,8 @@ trait Folders
public function DoFolderInformation() : array
{
$sFolder = $this->GetActionParam('Folder', '');
$sPrevUidNext = $this->GetActionParam('UidNext', '');
$aFlagsUids = array();
$sFlagsUids = (string) $this->GetActionParam('FlagsUids', '');
$aFlagsFilteredUids = array();
if (0 < strlen($sFlagsUids))
{
$aFlagsUids = \explode(',', $sFlagsUids);
$aFlagsFilteredUids = \array_filter(\array_map('intval', $aFlagsUids));
}
$iPrevUidNext = (int) $this->GetActionParam('UidNext', 0);
$aFlagsUids = \array_filter(\array_map('intval', $this->GetActionParam('FlagsUids', []))) ?: [];
$this->initMailClientConnection();
@ -354,7 +346,7 @@ trait Folders
try
{
$aInboxInformation = $this->MailClient()->FolderInformation(
$sFolder, $sPrevUidNext, $aFlagsFilteredUids
$sFolder, $iPrevUidNext, $aFlagsUids
);
foreach ($aInboxInformation['Flags'] as $iUid => $aFlags)
@ -401,11 +393,11 @@ trait Folders
$aFolders = \array_unique($aFolders);
foreach ($aFolders as $sFolder)
{
if (0 < \strlen(\trim($sFolder)) && 'INBOX' !== \strtoupper($sFolder))
if (0 < \strlen($sFolder) && 'INBOX' !== \strtoupper($sFolder))
{
try
{
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder, '', array());
$aInboxInformation = $this->MailClient()->FolderInformation($sFolder);
if (isset($aInboxInformation['Folder']))
{
$aResult['List'][] = [

View file

@ -21,9 +21,9 @@ trait Messages
$iOffset = 0;
$iLimit = 20;
$sSearch = '';
$sUidNext = '';
$iUidNext = 0;
$bUseThreads = false;
$sThreadUid = '';
$iThreadUid = '';
$sSort = '';
$sRawKey = $this->GetActionParam('RawKey', '');
@ -35,12 +35,12 @@ trait Messages
$iOffset = (int) $aValues[3];
$iLimit = (int) $aValues[4];
$sSearch = (string) $aValues[5];
$sUidNext = (string) $aValues[6];
$iUidNext = (int) $aValues[6];
$bUseThreads = (bool) $aValues[7];
if ($bUseThreads)
{
$sThreadUid = isset($aValues[8]) ? (string) $aValues[8] : '';
$iThreadUid = isset($aValues[8]) ? (int) $aValues[8] : 0;
}
$sSort = isset($aValues[9]) ? (string) $aValues[9] : '';
@ -54,12 +54,12 @@ trait Messages
$iLimit = (int) $this->GetActionParam('Limit', 10);
$sSearch = $this->GetActionParam('Search', '');
$sSort = $this->GetActionParam('Sort', '');
$sUidNext = $this->GetActionParam('UidNext', '');
$iUidNext = (int) $this->GetActionParam('UidNext', 0);
$bUseThreads = !empty($this->GetActionParam('UseThreads', '0'));
if ($bUseThreads)
{
$sThreadUid = (string) $this->GetActionParam('ThreadUid', '');
$iThreadUid = (int) $this->GetActionParam('ThreadUid', '');
}
}
@ -78,11 +78,11 @@ trait Messages
}
$oMessageList = $this->MailClient()->MessageList(
$sFolder, $iOffset, $iLimit, $sSearch, $sUidNext,
$sFolder, $iOffset, $iLimit, $sSearch, $iUidNext,
$this->cacherForUids(),
!!$this->Config()->Get('labs', 'use_imap_sort', true),
$bUseThreads,
$sThreadUid,
$iThreadUid,
'',
$sSort
);
@ -110,7 +110,7 @@ trait Messages
}
$sMessageFolder = $this->GetActionParam('MessageFolder', '');
$sMessageUid = $this->GetActionParam('MessageUid', '');
$iMessageUid = $this->GetActionParam('MessageUid', 0);
$sDraftFolder = $this->GetActionParam('SaveFolder', '');
if (0 === strlen($sDraftFolder))
@ -149,9 +149,9 @@ trait Messages
$mResult = true;
if (0 < strlen($sMessageFolder) && 0 < strlen($sMessageUid))
if (0 < strlen($sMessageFolder) && 0 < $iMessageUid)
{
$this->MailClient()->MessageDelete($sMessageFolder, array($sMessageUid), true, true);
$this->MailClient()->MessageDelete($sMessageFolder, array($iMessageUid), true, true);
}
if (null !== $iNewUid && 0 < $iNewUid)
@ -179,7 +179,7 @@ trait Messages
$oConfig = $this->Config();
$sDraftFolder = $this->GetActionParam('MessageFolder', '');
$sDraftUid = $this->GetActionParam('MessageUid', '');
$iDraftUid = $this->GetActionParam('MessageUid', 0);
$sSentFolder = $this->GetActionParam('SaveFolder', '');
$aDraftInfo = $this->GetActionParam('DraftInfo', null);
$bDsn = '1' === (string) $this->GetActionParam('Dsn', '0');
@ -287,11 +287,11 @@ trait Messages
$this->deleteMessageAttachmnets($oAccount);
if (0 < \strlen($sDraftFolder) && 0 < \strlen($sDraftUid))
if (0 < \strlen($sDraftFolder) && 0 < $iDraftUid)
{
try
{
$this->MailClient()->MessageDelete($sDraftFolder, array($sDraftUid), true, true);
$this->MailClient()->MessageDelete($sDraftFolder, array($iDraftUid), true, true);
}
catch (\Throwable $oException)
{
@ -388,15 +388,15 @@ trait Messages
if (!empty($sReadReceiptFlag))
{
$sFolderFullName = $this->GetActionParam('MessageFolder', '');
$sUid = $this->GetActionParam('MessageUid', '');
$iUid = (int) $this->GetActionParam('MessageUid', 0);
$this->Cacher($oAccount)->Set(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $sFolderFullName, $sUid), '1');
$this->Cacher($oAccount)->Set(\RainLoop\KeyPathHelper::ReadReceiptCache($oAccount->Email(), $sFolderFullName, $iUid), '1');
if (0 < \strlen($sFolderFullName) && 0 < \strlen($sUid))
if (0 < \strlen($sFolderFullName) && 0 < $iUid)
{
try
{
$this->MailClient()->MessageSetFlag($sFolderFullName, array($sUid), true, $sReadReceiptFlag, true, true);
$this->MailClient()->MessageSetFlag($sFolderFullName, array($iUid), true, $sReadReceiptFlag, true, true);
}
catch (\Throwable $oException) {}
}
@ -659,8 +659,8 @@ trait Messages
if ($aValues = \RainLoop\Utils::DecodeKeyValuesQ($sAttachment))
{
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
$sMimeIndex = isset($aValues['MimeIndex']) ? (string) $aValues['MimeIndex'] : '';
$sTempName = \md5($sAttachment);
if (!$this->FilesProvider()->FileExists($oAccount, $sTempName))

View file

@ -15,7 +15,7 @@ trait Raw
$aValues = $this->getDecodedRawKeyValue($sRawKey);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) (isset($aValues['Uid']) ? $aValues['Uid'] : 0);
$iUid = (isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0);
$sMimeIndex = (string) (isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '');
\header('Content-Type: text/plain');

View file

@ -416,7 +416,7 @@ trait Response
// $aExtended = array(
// 'MessageCount' => (int) $mStatus['MESSAGES'],
// 'MessageUnseenCount' => (int) $mStatus['UNSEEN'],
// 'UidNext' => (string) $mStatus['UIDNEXT'],
// 'UidNext' => (int) $mStatus['UIDNEXT'],
// 'Hash' => $this->MailClient()->GenerateFolderHash(
// $mResponse->FullNameRaw(), $mStatus['MESSAGES'], $mStatus['UNSEEN'], $mStatus['UIDNEXT'],
// empty($mStatus['HIGHESTMODSEQ']) ? '' : $mStatus['HIGHESTMODSEQ'])

View file

@ -541,7 +541,7 @@ trait User
$aValues = $this->getDecodedRawKeyValue($sHash);
$sFolder = isset($aValues['Folder']) ? $aValues['Folder'] : '';
$iUid = (int) isset($aValues['Uid']) ? $aValues['Uid'] : 0;
$iUid = isset($aValues['Uid']) ? (int) $aValues['Uid'] : 0;
$sMimeIndex = (string) isset($aValues['MimeIndex']) ? $aValues['MimeIndex'] : '';
$sContentTypeIn = (string) isset($aValues['MimeType']) ? $aValues['MimeType'] : '';

View file

@ -30,9 +30,9 @@ class KeyPathHelper
return '/RepositoryCache/CoreRepo/'.$sRepo;
}
static public function ReadReceiptCache(string $sEmail, string $sFolderFullName, string $sUid) : string
static public function ReadReceiptCache(string $sEmail, string $sFolderFullName, int $iUid) : string
{
return '/ReadReceipt/'.$sEmail.'/'.$sFolderFullName.'/'.$sUid;
return '/ReadReceipt/'.$sEmail.'/'.$sFolderFullName.'/'.$iUid;
}
static public function LangCache(string $sLanguage, bool $bAdmim, string $sPluginsHash) : string

View file

@ -169,7 +169,7 @@
</div>
</div>
<div class="b-content" data-bind="initDom: dragOverBodyArea">
<div class="listThreadUidDesc" data-bind="visible: '' !== messageListEndThreadUid(), click: cancelThreadUid">
<div class="listThreadUidDesc" data-bind="visible: 0 < messageListEndThreadUid(), click: cancelThreadUid">
<i class="fontastic"></i>
<span data-i18n="MESSAGE_LIST/BACK_TO_MESSAGE_LIST"></span>
</div>