mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-07 08:27:03 +03:00
Bugfix and improved Remote.message() and Remote.messageList() by using JSON
This commit is contained in:
parent
739aeaded5
commit
1767ba7ec9
3 changed files with 30 additions and 54 deletions
|
|
@ -19,13 +19,10 @@ import { AbstractFetchRemote } from 'Remote/AbstractFetch';
|
||||||
|
|
||||||
import { FolderCollectionModel } from 'Model/FolderCollection';
|
import { FolderCollectionModel } from 'Model/FolderCollection';
|
||||||
|
|
||||||
//const toUTF8 = window.TextEncoder
|
const urlSafeJSON = data => btoa(JSON.stringify(data))
|
||||||
// ? text => String.fromCharCode(...new TextEncoder().encode(text))
|
.replace(/\+/g, '-')
|
||||||
// : text => unescape(encodeURIComponent(text)),
|
.replace(/\//g, '_')
|
||||||
const urlsafeArray = array => btoa(unescape(encodeURIComponent(array.join('\x00').replace(/\r\n/g, '\n'))))
|
.replace(/=+$/, '');
|
||||||
.replace('+', '-')
|
|
||||||
.replace('/', '_')
|
|
||||||
.replace('=', '');
|
|
||||||
|
|
||||||
class RemoteUserFetch extends AbstractFetchRemote {
|
class RemoteUserFetch extends AbstractFetchRemote {
|
||||||
/**
|
/**
|
||||||
|
|
@ -185,22 +182,22 @@ class RemoteUserFetch extends AbstractFetchRemote {
|
||||||
messageList(fCallback, params, bSilent = false) {
|
messageList(fCallback, params, bSilent = false) {
|
||||||
const
|
const
|
||||||
sFolderFullNameRaw = pString(params.Folder),
|
sFolderFullNameRaw = pString(params.Folder),
|
||||||
folderHash = getFolderHash(sFolderFullNameRaw),
|
folderHash = getFolderHash(sFolderFullNameRaw);
|
||||||
useThreads = AppUserStore.threadsAllowed() && SettingsUserStore.useThreads() ? 1 : 0,
|
|
||||||
inboxUidNext = getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : '';
|
|
||||||
|
|
||||||
params.Folder = sFolderFullNameRaw;
|
|
||||||
params.ThreadUid = useThreads ? params.ThreadUid : 0;
|
|
||||||
params = Object.assign({
|
params = Object.assign({
|
||||||
Folder: '',
|
|
||||||
Offset: 0,
|
Offset: 0,
|
||||||
Limit: SettingsUserStore.messagesPerPage(),
|
Limit: SettingsUserStore.messagesPerPage(),
|
||||||
Search: '',
|
Search: '',
|
||||||
UidNext: inboxUidNext,
|
UidNext: getFolderInboxName() === sFolderFullNameRaw ? getFolderUidNext(sFolderFullNameRaw) : '',
|
||||||
UseThreads: useThreads,
|
Sort: FolderUserStore.sortMode(),
|
||||||
ThreadUid: 0,
|
Hash: folderHash + SettingsGet('AccountHash')
|
||||||
Sort: FolderUserStore.sortMode()
|
|
||||||
}, params);
|
}, params);
|
||||||
|
params.Folder = sFolderFullNameRaw;
|
||||||
|
if (AppUserStore.threadsAllowed() && SettingsUserStore.useThreads()) {
|
||||||
|
params.UseThreads = 1;
|
||||||
|
} else {
|
||||||
|
params.ThreadUid = 0;
|
||||||
|
}
|
||||||
|
|
||||||
let sGetAdd = '';
|
let sGetAdd = '';
|
||||||
|
|
||||||
|
|
@ -208,7 +205,7 @@ class RemoteUserFetch extends AbstractFetchRemote {
|
||||||
sGetAdd = 'MessageList/' +
|
sGetAdd = 'MessageList/' +
|
||||||
SUB_QUERY_PREFIX +
|
SUB_QUERY_PREFIX +
|
||||||
'/' +
|
'/' +
|
||||||
urlsafeArray([SettingsGet('ProjectHash'),folderHash].concat(Object.values(params)));
|
urlSafeJSON(params);
|
||||||
params = {};
|
params = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -256,11 +253,11 @@ class RemoteUserFetch extends AbstractFetchRemote {
|
||||||
'Message/' +
|
'Message/' +
|
||||||
SUB_QUERY_PREFIX +
|
SUB_QUERY_PREFIX +
|
||||||
'/' +
|
'/' +
|
||||||
urlsafeArray([
|
urlSafeJSON([
|
||||||
sFolderFullNameRaw,
|
sFolderFullNameRaw,
|
||||||
iUid,
|
iUid,
|
||||||
SettingsGet('ProjectHash'),
|
AppUserStore.threadsAllowed() && SettingsUserStore.useThreads() ? 1 : 0,
|
||||||
AppUserStore.threadsAllowed() && SettingsUserStore.useThreads() ? 1 : 0
|
SettingsGet('AccountHash')
|
||||||
]),
|
]),
|
||||||
['Message']
|
['Message']
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -1026,8 +1026,6 @@ class Actions
|
||||||
$aResult['Capa'] = $this->Capa(true);
|
$aResult['Capa'] = $this->Capa(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
$aResult['ProjectHash'] = \md5($aResult['AccountHash'] . APP_VERSION . $this->Plugins()->Hash());
|
|
||||||
|
|
||||||
$sStaticCache = $this->StaticCache();
|
$sStaticCache = $this->StaticCache();
|
||||||
|
|
||||||
$aResult['Theme'] = $this->GetTheme($bAdmin);
|
$aResult['Theme'] = $this->GetTheme($bAdmin);
|
||||||
|
|
|
||||||
|
|
@ -27,22 +27,19 @@ trait Messages
|
||||||
$sSort = '';
|
$sSort = '';
|
||||||
|
|
||||||
$sRawKey = $this->GetActionParam('RawKey', '');
|
$sRawKey = $this->GetActionParam('RawKey', '');
|
||||||
$aValues = $this->getDecodedClientRawKeyValue($sRawKey, 10);
|
$aValues = \json_decode(\MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey), true);
|
||||||
if ($aValues && 7 < \count($aValues))
|
if ($aValues && 7 < \count($aValues))
|
||||||
{
|
{
|
||||||
$sFolder = (string) $aValues[2];
|
$sFolder = (string) $aValues['Folder'];
|
||||||
$iOffset = (int) $aValues[3];
|
$iOffset = (int) $aValues['Offset'];
|
||||||
$iLimit = (int) $aValues[4];
|
$iLimit = (int) $aValues['Limit'];
|
||||||
$sSearch = (string) $aValues[5];
|
$sSearch = (string) $aValues['Search'];
|
||||||
$iUidNext = (int) $aValues[6];
|
$iUidNext = (int) $aValues['UidNext'];
|
||||||
$bUseThreads = (bool) $aValues[7];
|
$bUseThreads = !empty($aValues['UseThreads']);
|
||||||
|
if ($bUseThreads) {
|
||||||
if ($bUseThreads)
|
$iThreadUid = (int) $aValues['ThreadUid'];
|
||||||
{
|
|
||||||
$iThreadUid = isset($aValues[8]) ? (int) $aValues[8] : 0;
|
|
||||||
}
|
}
|
||||||
|
$sSort = (string) $aValues['Sort'];
|
||||||
$sSort = isset($aValues[9]) ? (string) $aValues[9] : '';
|
|
||||||
|
|
||||||
$this->verifyCacheByKey($sRawKey);
|
$this->verifyCacheByKey($sRawKey);
|
||||||
}
|
}
|
||||||
|
|
@ -445,8 +442,8 @@ trait Messages
|
||||||
$sFolder = '';
|
$sFolder = '';
|
||||||
$iUid = 0;
|
$iUid = 0;
|
||||||
|
|
||||||
$aValues = $this->getDecodedClientRawKeyValue($sRawKey, 4);
|
$aValues = \json_decode(\MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey), true);
|
||||||
if ($aValues && 4 === count($aValues))
|
if ($aValues && 2 <= \count($aValues))
|
||||||
{
|
{
|
||||||
$sFolder = (string) $aValues[0];
|
$sFolder = (string) $aValues[0];
|
||||||
$iUid = (int) $aValues[1];
|
$iUid = (int) $aValues[1];
|
||||||
|
|
@ -846,22 +843,6 @@ trait Messages
|
||||||
return $this->TrueResponse($sResponseFunction);
|
return $this->TrueResponse($sResponseFunction);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getDecodedClientRawKeyValue(string $sRawKey, ?int $iLenCache = null) : ?array
|
|
||||||
{
|
|
||||||
if (!empty($sRawKey))
|
|
||||||
{
|
|
||||||
$sRawKey = \MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey);
|
|
||||||
$aValues = explode("\x0", $sRawKey);
|
|
||||||
|
|
||||||
if (null === $iLenCache || $iLenCache === count($aValues))
|
|
||||||
{
|
|
||||||
return $aValues;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private function deleteMessageAttachmnets(Account $oAccount) : void
|
private function deleteMessageAttachmnets(Account $oAccount) : void
|
||||||
{
|
{
|
||||||
$aAttachments = $this->GetActionParam('Attachments', null);
|
$aAttachments = $this->GetActionParam('Attachments', null);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue