mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Remove Model\Account param from encodeRawKey/decodeRawKey
This commit is contained in:
parent
eaf4bbe6d3
commit
e2ed87a1ab
6 changed files with 12 additions and 15 deletions
|
|
@ -66,7 +66,7 @@ class Attachment implements \JsonSerializable
|
||||||
], $this->oBodyStructure->jsonSerialize());
|
], $this->oBodyStructure->jsonSerialize());
|
||||||
$aResult['isThumbnail'] = \MailSo\Base\Utils::fileHasThumbnail($aResult['fileName']);
|
$aResult['isThumbnail'] = \MailSo\Base\Utils::fileHasThumbnail($aResult['fileName']);
|
||||||
$oActions = \RainLoop\Api::Actions();
|
$oActions = \RainLoop\Api::Actions();
|
||||||
$aResult['download'] = $oActions->encodeRawKey($oActions->getAccountFromToken(), array(
|
$aResult['download'] = $oActions->encodeRawKey(array(
|
||||||
'folder' => $aResult['folder'],
|
'folder' => $aResult['folder'],
|
||||||
'uid' => $aResult['uid'],
|
'uid' => $aResult['uid'],
|
||||||
'mimeIndex' => $aResult['mimeIndex'],
|
'mimeIndex' => $aResult['mimeIndex'],
|
||||||
|
|
|
||||||
|
|
@ -1054,7 +1054,7 @@ class Actions
|
||||||
{
|
{
|
||||||
if ($sKey && $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));
|
\MailSo\Base\Http::checkETag($this->etag($sKey));
|
||||||
// \MailSo\Base\Http::checkLastModified(1382478804);
|
// \MailSo\Base\Http::checkLastModified(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1078,15 +1078,15 @@ class Actions
|
||||||
return $oAccount;
|
return $oAccount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function encodeRawKey(?Model\Account $oAccount, array $aValues): string
|
public function encodeRawKey(array $aValues): string
|
||||||
{
|
{
|
||||||
return \SnappyMail\Crypt::EncryptUrlSafe($aValues, \sha1(APP_SALT . ($oAccount ? $oAccount->Hash() : '')));
|
return \SnappyMail\Crypt::EncryptUrlSafe($aValues, \sha1(APP_SALT . $this->getAccountFromToken()->Hash()));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function decodeRawKey(?Model\Account $oAccount, string $sRawKey): array
|
protected function decodeRawKey(string $sRawKey): array
|
||||||
{
|
{
|
||||||
return empty($sRawKey) ? []
|
return empty($sRawKey) ? []
|
||||||
: (\SnappyMail\Crypt::DecryptUrlSafe($sRawKey, \sha1(APP_SALT . ($oAccount ? $oAccount->Hash() : ''))) ?: []);
|
: (\SnappyMail\Crypt::DecryptUrlSafe($sRawKey, \sha1(APP_SALT . $this->getAccountFromToken()->Hash())) ?: []);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function StaticCache(): string
|
public function StaticCache(): string
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,7 @@ trait Attachments
|
||||||
|
|
||||||
if (!$bError) {
|
if (!$bError) {
|
||||||
$mResult = array(
|
$mResult = array(
|
||||||
'fileHash' => $this->encodeRawKey($oAccount, array(
|
'fileHash' => $this->encodeRawKey(array(
|
||||||
'fileName' => ($sFilename ?: ($sFolder ? 'messages' : 'attachments')) . \date('-YmdHis') . '.zip',
|
'fileName' => ($sFilename ?: ($sFolder ? 'messages' : 'attachments')) . \date('-YmdHis') . '.zip',
|
||||||
'mimeType' => 'application/zip',
|
'mimeType' => 'application/zip',
|
||||||
'fileHash' => $sZipHash
|
'fileHash' => $sZipHash
|
||||||
|
|
@ -134,7 +134,7 @@ trait Attachments
|
||||||
|
|
||||||
private function getMimeFileByHash(\RainLoop\Model\Account $oAccount, string $sHash) : array
|
private function getMimeFileByHash(\RainLoop\Model\Account $oAccount, string $sHash) : array
|
||||||
{
|
{
|
||||||
$aValues = $this->decodeRawKey($oAccount, $sHash);
|
$aValues = $this->decodeRawKey($sHash);
|
||||||
|
|
||||||
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
||||||
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
||||||
|
|
|
||||||
|
|
@ -575,7 +575,7 @@ trait Messages
|
||||||
$oFilesProvider = $this->FilesProvider();
|
$oFilesProvider = $this->FilesProvider();
|
||||||
foreach ($aAttachments as $mIndex => $sAttachment) {
|
foreach ($aAttachments as $mIndex => $sAttachment) {
|
||||||
$aAttachments[$mIndex] = false;
|
$aAttachments[$mIndex] = false;
|
||||||
if ($aValues = $this->decodeRawKey($oAccount, $sAttachment)) {
|
if ($aValues = $this->decodeRawKey($sAttachment)) {
|
||||||
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
||||||
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
||||||
$sMimeIndex = isset($aValues['mimeIndex']) ? (string) $aValues['mimeIndex'] : '';
|
$sMimeIndex = isset($aValues['mimeIndex']) ? (string) $aValues['mimeIndex'] : '';
|
||||||
|
|
|
||||||
|
|
@ -11,10 +11,7 @@ trait Raw
|
||||||
{
|
{
|
||||||
$oAccount = $this->initMailClientConnection();
|
$oAccount = $this->initMailClientConnection();
|
||||||
|
|
||||||
$aValues = $this->decodeRawKey(
|
$aValues = $this->decodeRawKey((string) $this->GetActionParam('RawKey', ''));
|
||||||
$oAccount,
|
|
||||||
(string) $this->GetActionParam('RawKey', '')
|
|
||||||
);
|
|
||||||
|
|
||||||
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
|
||||||
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
|
||||||
|
|
@ -111,7 +108,7 @@ trait Raw
|
||||||
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
$sRawKey = (string) $this->GetActionParam('RawKey', '');
|
||||||
|
|
||||||
$oAccount = $this->getAccountFromToken();
|
$oAccount = $this->getAccountFromToken();
|
||||||
$aValues = $this->decodeRawKey($oAccount, $sRawKey);
|
$aValues = $this->decodeRawKey($sRawKey);
|
||||||
|
|
||||||
$sRange = \MailSo\Base\Http::GetHeader('Range');
|
$sRange = \MailSo\Base\Http::GetHeader('Range');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -109,7 +109,7 @@ trait Response
|
||||||
}
|
}
|
||||||
|
|
||||||
$sSubject = $aResult['subject'];
|
$sSubject = $aResult['subject'];
|
||||||
$aResult['requestHash'] = $this->encodeRawKey($oAccount, array(
|
$aResult['requestHash'] = $this->encodeRawKey(array(
|
||||||
'folder' => $aResult['folder'],
|
'folder' => $aResult['folder'],
|
||||||
'uid' => $aResult['uid'],
|
'uid' => $aResult['uid'],
|
||||||
'mimeType' => 'message/rfc822',
|
'mimeType' => 'message/rfc822',
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue