Remove Model\Account param from encodeRawKey/decodeRawKey

This commit is contained in:
the-djmaze 2023-03-07 08:03:15 +01:00
parent eaf4bbe6d3
commit e2ed87a1ab
6 changed files with 12 additions and 15 deletions

View file

@ -66,7 +66,7 @@ class Attachment implements \JsonSerializable
], $this->oBodyStructure->jsonSerialize());
$aResult['isThumbnail'] = \MailSo\Base\Utils::fileHasThumbnail($aResult['fileName']);
$oActions = \RainLoop\Api::Actions();
$aResult['download'] = $oActions->encodeRawKey($oActions->getAccountFromToken(), array(
$aResult['download'] = $oActions->encodeRawKey(array(
'folder' => $aResult['folder'],
'uid' => $aResult['uid'],
'mimeIndex' => $aResult['mimeIndex'],

View file

@ -1054,7 +1054,7 @@ class Actions
{
if ($sKey && $this->oConfig->Get('cache', 'enable', true) && $this->oConfig->Get('cache', 'http', true)) {
\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;
}
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) ? []
: (\SnappyMail\Crypt::DecryptUrlSafe($sRawKey, \sha1(APP_SALT . ($oAccount ? $oAccount->Hash() : ''))) ?: []);
: (\SnappyMail\Crypt::DecryptUrlSafe($sRawKey, \sha1(APP_SALT . $this->getAccountFromToken()->Hash())) ?: []);
}
public function StaticCache(): string

View file

@ -108,7 +108,7 @@ trait Attachments
if (!$bError) {
$mResult = array(
'fileHash' => $this->encodeRawKey($oAccount, array(
'fileHash' => $this->encodeRawKey(array(
'fileName' => ($sFilename ?: ($sFolder ? 'messages' : 'attachments')) . \date('-YmdHis') . '.zip',
'mimeType' => 'application/zip',
'fileHash' => $sZipHash
@ -134,7 +134,7 @@ trait Attachments
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'] : '';
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;

View file

@ -575,7 +575,7 @@ trait Messages
$oFilesProvider = $this->FilesProvider();
foreach ($aAttachments as $mIndex => $sAttachment) {
$aAttachments[$mIndex] = false;
if ($aValues = $this->decodeRawKey($oAccount, $sAttachment)) {
if ($aValues = $this->decodeRawKey($sAttachment)) {
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
$sMimeIndex = isset($aValues['mimeIndex']) ? (string) $aValues['mimeIndex'] : '';

View file

@ -11,10 +11,7 @@ trait Raw
{
$oAccount = $this->initMailClientConnection();
$aValues = $this->decodeRawKey(
$oAccount,
(string) $this->GetActionParam('RawKey', '')
);
$aValues = $this->decodeRawKey((string) $this->GetActionParam('RawKey', ''));
$sFolder = isset($aValues['folder']) ? (string) $aValues['folder'] : '';
$iUid = isset($aValues['uid']) ? (int) $aValues['uid'] : 0;
@ -111,7 +108,7 @@ trait Raw
$sRawKey = (string) $this->GetActionParam('RawKey', '');
$oAccount = $this->getAccountFromToken();
$aValues = $this->decodeRawKey($oAccount, $sRawKey);
$aValues = $this->decodeRawKey($sRawKey);
$sRange = \MailSo\Base\Http::GetHeader('Range');

View file

@ -109,7 +109,7 @@ trait Response
}
$sSubject = $aResult['subject'];
$aResult['requestHash'] = $this->encodeRawKey($oAccount, array(
$aResult['requestHash'] = $this->encodeRawKey(array(
'folder' => $aResult['folder'],
'uid' => $aResult['uid'],
'mimeType' => 'message/rfc822',