Update packages and notification settings

This commit is contained in:
James Cole
2024-12-14 05:39:55 +01:00
parent 0e5eb036b0
commit abad7cdf16
8 changed files with 623 additions and 559 deletions

View File

@@ -56,13 +56,13 @@ class FireflyConfig
return null;
}
if ('' === $result->data) {
Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));
Log::warning(sprintf('Empty encrypted configuration value found: "%s"', $name));
return $result;
}
try {
$result->data = decrypt($result->data);
} catch (DecryptException $e) {
Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));
Log::error(sprintf('Could not decrypt configuration value "%s": %s', $name, $e->getMessage()));
return $result;
}
return $result;
@@ -105,8 +105,8 @@ class FireflyConfig
try {
$encrypted = encrypt($value);
} catch (EncryptException $e) {
Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));
throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));
Log::error(sprintf('Could not encrypt configuration value "%s": %s', $name, $e->getMessage()));
throw new FireflyException(sprintf('Could not encrypt configuration value "%s". Cowardly refuse to continue.', $name));
}
return $this->set($name, $encrypted);
}

View File

@@ -26,9 +26,12 @@ namespace FireflyIII\Support;
use FireflyIII\Exceptions\FireflyException;
use FireflyIII\Models\Preference;
use FireflyIII\User;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
/**
@@ -53,6 +56,37 @@ class Preferences
;
}
public function getEncrypted(string $name, $default = null): ?Preference
{
$result = $this->get($name, $default);
if (null === $result) {
return null;
}
if ('' === $result->data) {
Log::warning(sprintf('Empty encrypted preference found: "%s"', $name));
return $result;
}
try {
$result->data = decrypt($result->data);
} catch (DecryptException $e) {
Log::error(sprintf('Could not decrypt preference "%s": %s', $name, $e->getMessage()));
return $result;
}
return $result;
}
public function setEncrypted(string $name, mixed $value): Preference
{
try {
$encrypted = encrypt($value);
} catch (EncryptException $e) {
Log::error(sprintf('Could not encrypt preference "%s": %s', $name, $e->getMessage()));
throw new FireflyException(sprintf('Could not encrypt preference "%s". Cowardly refuse to continue.', $name));
}
return $this->set($name, $encrypted);
}
public function get(string $name, null|array|bool|int|string $default = null): ?Preference
{
/** @var null|User $user */