From 1833388ea4f84ae472490e7380f6097c8a3831e6 Mon Sep 17 00:00:00 2001 From: the-djmaze <> Date: Tue, 22 Mar 2022 15:36:10 +0100 Subject: [PATCH] Resolve #299 due to changes of #287 --- .../0.0.0/app/libraries/RainLoop/Actions.php | 37 ++++++++++--------- .../libraries/RainLoop/Actions/Accounts.php | 6 +-- .../Providers/Storage/FileStorage.php | 4 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php index 987ade1d0..72d4efb22 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions.php @@ -225,10 +225,12 @@ class Actions APP_PRIVATE_DATA . 'storage', 'storage-local' === $sName); break; case 'settings': + // RainLoop\Providers\Settings\ISettings + $mResult = new Providers\Settings\DefaultSettings($this->StorageProvider()); + break; case 'settings-local': // RainLoop\Providers\Settings\ISettings - $mResult = new Providers\Settings\DefaultSettings( - $this->StorageProvider('settings-local' === $sName)); + $mResult = new Providers\Settings\DefaultSettings($this->LocalStorageProvider()); break; case 'login': // Providers\Login\LoginInterface @@ -267,7 +269,7 @@ class Actions // Always give the file provider as last for identities, it is the override if ('identities' === $sName) { - $mResult[] = new Providers\Identities\FileIdentities($this->StorageProvider(true)); + $mResult[] = new Providers\Identities\FileIdentities($this->LocalStorageProvider()); } foreach (\is_array($mResult) ? $mResult : array($mResult) as $oItem) { @@ -444,23 +446,22 @@ class Actions return $this->oMailClient; } - public function StorageProvider(bool $bLocal = false): Providers\Storage + // Stores data in AdditionalAccount else MainAccount + public function LocalStorageProvider(): Providers\Storage { - if ($bLocal) { - if (!$this->oLocalStorageProvider) { - $this->oLocalStorageProvider = new Providers\Storage( - $this->fabrica('storage-local')); - } - - return $this->oLocalStorageProvider; - } else { - if (!$this->oStorageProvider) { - $this->oStorageProvider = new Providers\Storage( - $this->fabrica('storage')); - } - - return $this->oStorageProvider; + if (!$this->oLocalStorageProvider) { + $this->oLocalStorageProvider = new Providers\Storage($this->fabrica('storage-local')); } + return $this->oLocalStorageProvider; + } + + // Stores data in MainAccount + public function StorageProvider(): Providers\Storage + { + if (!$this->oStorageProvider) { + $this->oStorageProvider = new Providers\Storage($this->fabrica('storage')); + } + return $this->oStorageProvider; } public function SettingsProvider(bool $bLocal = false): Providers\Settings diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php index c0031fc6d..1974fc05e 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Actions/Accounts.php @@ -224,7 +224,7 @@ trait Accounts $this->SetAccounts($oAccount, $aAccounts); } - return $this->DefaultResponse(__FUNCTION__, $this->StorageProvider()->Put( + return $this->DefaultResponse(__FUNCTION__, $this->LocalStorageProvider()->Put( $this->getAccountFromToken(), StorageType::CONFIG, 'identities_order', @@ -260,7 +260,7 @@ trait Accounts $identities = $this->IdentitiesProvider()->GetIdentities($oAccount, $allowMultipleIdentities); // Sort identities - $orderString = $this->StorageProvider()->Get($oAccount, StorageType::CONFIG, 'identities_order'); + $orderString = $this->LocalStorageProvider()->Get($oAccount, StorageType::CONFIG, 'identities_order'); $old = false; if (!$orderString) { $orderString = $this->StorageProvider()->Get($oAccount, StorageType::CONFIG, 'accounts_identities_order'); @@ -279,7 +279,7 @@ trait Accounts } if ($old) { - $this->StorageProvider()->Put( + $this->LocalStorageProvider()->Put( $oAccount, StorageType::CONFIG, 'identities_order', diff --git a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php index e31e03f9f..1717e442f 100644 --- a/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php +++ b/snappymail/v/0.0.0/app/libraries/RainLoop/Providers/Storage/FileStorage.php @@ -98,7 +98,9 @@ class FileStorage implements \RainLoop\Providers\Storage\IStorage $sEmail = $mAccount->Email(); } else if ($mAccount instanceof \RainLoop\Model\AdditionalAccount) { $sEmail = $mAccount->ParentEmail(); - $sSubFolder = $mAccount->Email(); + if ($this->bLocal) { + $sSubFolder = $mAccount->Email(); + } } else if (\is_string($mAccount)) { $sEmail = $mAccount; }