mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-11-01 18:08:49 +03:00
Merge branch 'master' of https://github.com/cm-schl/snappymail
This commit is contained in:
commit
f10f93fd8f
18 changed files with 137 additions and 128 deletions
|
|
@ -582,11 +582,11 @@ class MailClient
|
|||
$sSerializedHash = '';
|
||||
$sSerializedLog = '';
|
||||
if ($bUseCacheAfterSearch) {
|
||||
$sSerializedHash = 'GetUids/'.
|
||||
($bUseSort ? 'S' . $sSort : 'N').'/'.
|
||||
$this->oImapClient->Hash().'/'.
|
||||
$sFolderName.'/'.$sSearchCriterias;
|
||||
$sSerializedLog = '"'.$sFolderName.'" / '.$sSearchCriterias.'';
|
||||
$sSerializedHash = 'Get'
|
||||
. ($bReturnUid ? 'UIDS/' : 'IDS/')
|
||||
. ($bUseSort ? 'S' . $sSort : 'N')
|
||||
. "/{$this->oImapClient->Hash()}/{$sFolderName}/{$sSearchCriterias}";
|
||||
$sSerializedLog = "\"{$sFolderName}\" / {$sSort} / {$sSearchCriterias}";
|
||||
|
||||
$sSerialized = $oCacher->Get($sSerializedHash);
|
||||
if (!empty($sSerialized)) {
|
||||
|
|
@ -596,11 +596,9 @@ class MailClient
|
|||
\is_array($aSerialized['Uids'])
|
||||
) {
|
||||
if ($this->oLogger) {
|
||||
$this->oLogger->Write('Get Serialized UIDS from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']');
|
||||
}
|
||||
if (\is_array($aSerialized['Uids'])) {
|
||||
return $aSerialized['Uids'];
|
||||
$this->oLogger->Write('Get Serialized '.($bReturnUid?'UIDS':'IDS').' from cache ('.$sSerializedLog.') [count:'.\count($aSerialized['Uids']).']');
|
||||
}
|
||||
return $aSerialized['Uids'];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -631,7 +629,7 @@ class MailClient
|
|||
)));
|
||||
|
||||
if ($this->oLogger) {
|
||||
$this->oLogger->Write('Save Serialized UIDS to cache ('.$sSerializedLog.') [count:'.\count($aResultUids).']');
|
||||
$this->oLogger->Write('Save Serialized '.($bReturnUid?'UIDS':'IDS').' to cache ('.$sSerializedLog.') [count:'.\count($aResultUids).']');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -51,4 +51,18 @@ class MessageListParams
|
|||
// 0 > $oParams->iLimit
|
||||
// 999 < $oParams->iLimit
|
||||
}
|
||||
|
||||
public function hash() : string
|
||||
{
|
||||
return \md5(\implode('-', [
|
||||
$this->sFolderName,
|
||||
$this->iOffset,
|
||||
$this->iLimit,
|
||||
$this->bHideDeleted ? '1' : '0',
|
||||
$this->sSearch,
|
||||
$this->bUseSort ? $this->sSort : '',
|
||||
$this->bUseThreads ? $this->iThreadUid : '',
|
||||
$this->iPrevUidNext
|
||||
]));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -157,7 +157,7 @@ class Header
|
|||
}
|
||||
|
||||
// https://www.rfc-editor.org/rfc/rfc2822#section-2.1.1
|
||||
return \wordwrap($this->NameWithDelimitrom() . $sValue, 78, "\r\n ");
|
||||
return \wordwrap($this->NameWithDelimitrom() . $sResult, 78, "\r\n ");
|
||||
}
|
||||
|
||||
public function IsSubject() : bool
|
||||
|
|
|
|||
|
|
@ -408,6 +408,12 @@ class Actions
|
|||
return $this->oMailClient;
|
||||
}
|
||||
|
||||
public function ImapClient(): \MailSo\Imap\ImapClient
|
||||
{
|
||||
// $this->initMailClientConnection();
|
||||
return $this->MailClient()->ImapClient();
|
||||
}
|
||||
|
||||
// Stores data in AdditionalAccount else MainAccount
|
||||
public function LocalStorageProvider(): Providers\Storage
|
||||
{
|
||||
|
|
@ -590,7 +596,7 @@ class Actions
|
|||
{
|
||||
$sLine = $this->oConfig->Get('logs', 'auth_logging_format', '');
|
||||
if (!empty($sLine)) {
|
||||
$this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams));
|
||||
$this->LoggerAuth()->Write($this->compileLogParams($sLine, $oAccount, false, $aAdditionalParams), \LOG_WARNING);
|
||||
}
|
||||
if (($this->oConfig->Get('logs', 'auth_logging', false) || $this->oConfig->Get('logs', 'auth_syslog', false))
|
||||
&& \openlog('snappymail', 0, \LOG_AUTHPRIV)) {
|
||||
|
|
@ -1066,9 +1072,9 @@ class Actions
|
|||
return \md5($sKey . $this->oConfig->Get('cache', 'index', ''));
|
||||
}
|
||||
|
||||
public function cacheByKey(string $sKey, bool $bForce = false): bool
|
||||
public function cacheByKey(string $sKey): bool
|
||||
{
|
||||
if ($sKey && ($bForce || ($this->oConfig->Get('cache', 'enable', true) && $this->oConfig->Get('cache', 'http', true)))) {
|
||||
if ($sKey && $this->oConfig->Get('cache', 'enable', true) && $this->oConfig->Get('cache', 'http', true)) {
|
||||
\MailSo\Base\Http::ServerUseCache(
|
||||
$this->etag($sKey),
|
||||
1382478804,
|
||||
|
|
@ -1080,11 +1086,11 @@ class Actions
|
|||
return false;
|
||||
}
|
||||
|
||||
public function verifyCacheByKey(string $sKey, bool $bForce = false): void
|
||||
public function verifyCacheByKey(string $sKey): void
|
||||
{
|
||||
if ($sKey && ($bForce || ($this->oConfig->Get('cache', 'enable', true) && $this->oConfig->Get('cache', 'http', true)))) {
|
||||
if ($sKey && $this->oConfig->Get('cache', 'enable', true) && $this->oConfig->Get('cache', 'http', true)) {
|
||||
\MailSo\Base\Http::checkETag($this->etag($sKey));
|
||||
// $this->cacheByKey($sKey, $bForce);
|
||||
// \MailSo\Base\Http::checkLastModified(1382478804);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace RainLoop\Actions;
|
|||
|
||||
use RainLoop\Enumerations\PluginPropertyType;
|
||||
use RainLoop\Exceptions\ClientException;
|
||||
use RainLoop\Notifications;
|
||||
|
||||
trait AdminExtensions
|
||||
{
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ trait Messages
|
|||
$oParams = new \MailSo\Mail\MessageListParams;
|
||||
|
||||
$sRawKey = $this->GetActionParam('RawKey', '');
|
||||
$aValues = \json_decode(\MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey), true);
|
||||
$aValues = $sRawKey ? \json_decode(\MailSo\Base\Utils::UrlSafeBase64Decode($sRawKey), true) : null;
|
||||
$sHash = '';
|
||||
if ($aValues && 6 < \count($aValues)) {
|
||||
$this->verifyCacheByKey($sRawKey);
|
||||
|
||||
// $oParams->sHash = (string) $aValues['Hash'];
|
||||
$oParams->sFolderName = (string) $aValues['Folder'];
|
||||
// GET
|
||||
$sHash = (string) $aValues['hash'];
|
||||
$oParams->sFolderName = (string) $aValues['folder'];
|
||||
$oParams->iLimit = $aValues['limit'];
|
||||
$oParams->iOffset = $aValues['offset'];
|
||||
$oParams->sSearch = (string) $aValues['search'];
|
||||
|
|
@ -42,7 +42,8 @@ trait Messages
|
|||
$oParams->iThreadUid = $aValues['threadUid'];
|
||||
}
|
||||
} else {
|
||||
$oParams->sFolderName = $this->GetActionParam('Folder', '');
|
||||
// POST
|
||||
$oParams->sFolderName = $this->GetActionParam('folder', '');
|
||||
$oParams->iOffset = $this->GetActionParam('offset', 0);
|
||||
$oParams->iLimit = $this->GetActionParam('limit', 10);
|
||||
$oParams->sSearch = $this->GetActionParam('search', '');
|
||||
|
|
@ -60,6 +61,16 @@ trait Messages
|
|||
|
||||
$oAccount = $this->initMailClientConnection();
|
||||
|
||||
if ($sHash) {
|
||||
$oInfo = $this->ImapClient()->FolderStatusAndSelect($oParams->sFolderName);
|
||||
$aRequestHash = \explode('-', $sHash);
|
||||
$sFolderHash = $oInfo->getHash($this->ImapClient()->Hash());
|
||||
$sHash = $oParams->hash() . '-' . $sFolderHash;
|
||||
if ($aRequestHash[0] == $sFolderHash) {
|
||||
$this->verifyCacheByKey($sHash);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!$this->Config()->Get('imap', 'use_thread', true)) {
|
||||
|
|
@ -75,17 +86,15 @@ trait Messages
|
|||
}
|
||||
|
||||
$oMessageList = $this->MailClient()->MessageList($oParams);
|
||||
if ($sHash) {
|
||||
$this->cacheByKey($sHash);
|
||||
}
|
||||
return $this->DefaultResponse($oMessageList);
|
||||
}
|
||||
catch (\Throwable $oException)
|
||||
{
|
||||
throw new ClientException(Notifications::CantGetMessageList, $oException);
|
||||
}
|
||||
|
||||
if ($oMessageList) {
|
||||
$this->cacheByKey($sRawKey);
|
||||
}
|
||||
|
||||
return $this->DefaultResponse($oMessageList);
|
||||
}
|
||||
|
||||
public function DoSaveMessage() : array
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Plugins;
|
||||
|
||||
use \RainLoop\Enumerations\PluginPropertyType;
|
||||
use RainLoop\Enumerations\PluginPropertyType;
|
||||
|
||||
class Property implements \JsonSerializable
|
||||
{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace RainLoop\Providers\AddressBook\Classes;
|
||||
|
||||
use \Sabre\VObject\Component\VCard;
|
||||
use Sabre\VObject\Component\VCard;
|
||||
|
||||
class Contact implements \JsonSerializable
|
||||
{
|
||||
|
|
|
|||
|
|
@ -160,14 +160,17 @@ class ServiceActions
|
|||
|
||||
$aResponse['Action'] = $sAction ?: 'Unknown';
|
||||
|
||||
if (\is_array($aResponse)) {
|
||||
$aResponse['Time'] = (int) ((\microtime(true) - $_SERVER['REQUEST_TIME_FLOAT']) * 1000);
|
||||
}
|
||||
|
||||
if (!\headers_sent()) {
|
||||
\header('Content-Type: application/json; charset=utf-8');
|
||||
}
|
||||
|
||||
if (\is_array($aResponse)) {
|
||||
$aResponse['epoch'] = \time();
|
||||
// if ($this->Config()->Get('debug', 'enable', false)) {
|
||||
// $aResponse['rtime'] = \round(\microtime(true) - $_SERVER['REQUEST_TIME_FLOAT'], 3);
|
||||
// }
|
||||
}
|
||||
|
||||
$sResult = Utils::jsonEncode($aResponse);
|
||||
|
||||
$sObResult = \ob_get_clean();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue