mirror of
https://github.com/mailcow/mailcow-dockerized.git
synced 2026-11-15 21:00:14 +00:00
[Web][Rspamd] Keep the global archive switch in Redis only
This commit is contained in:
15 files changed
+78
-55
No files matched your search
@@ -48,8 +48,7 @@ class JournalService
|
||||
public function prepare(array $request): array
|
||||
{
|
||||
$settings = $this->settings->load();
|
||||
$this->state->setEnabled($settings->enabled);
|
||||
if (!$settings->enabled || !$settings->canDeliver()) {
|
||||
if (!$this->state->enabled() || !$settings->canDeliver()) {
|
||||
return ['archive' => false];
|
||||
}
|
||||
$from = self::text($request['from'] ?? '');
|
||||
@@ -75,7 +74,7 @@ class JournalService
|
||||
{
|
||||
try {
|
||||
$settings = $this->settings->load();
|
||||
if (!$settings->enabled || !$settings->canDeliver()) {
|
||||
if (!$this->state->enabled() || !$settings->canDeliver()) {
|
||||
return false;
|
||||
}
|
||||
$resolved = $this->resolver->resolve($from, $rcpts, '', false);
|
||||
|
||||
@@ -5,8 +5,8 @@ declare(strict_types=1);
|
||||
namespace Mailcow\Archive\Service;
|
||||
|
||||
use Mailcow\Archive\Model\Mailbox;
|
||||
use Mailcow\Archive\Redis\ArchiveState;
|
||||
use Mailcow\Archive\Repository\LookupRepository;
|
||||
use Mailcow\Archive\Repository\SettingsRepository;
|
||||
use Mailcow\Core\AccessDenied;
|
||||
use Mailcow\Core\Context;
|
||||
|
||||
@@ -16,7 +16,7 @@ use Mailcow\Core\Context;
|
||||
*/
|
||||
class MailboxListService
|
||||
{
|
||||
public function __construct(private LookupRepository $lookup, private SettingsRepository $settings, private Context $context)
|
||||
public function __construct(private LookupRepository $lookup, private ArchiveState $state, private Context $context)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ class MailboxListService
|
||||
public function archived(): array
|
||||
{
|
||||
$this->context->requireAdmin(false);
|
||||
$enabled = $this->settings->load()->enabled;
|
||||
$enabled = $this->state->enabled();
|
||||
return [
|
||||
'enabled' => (int)$enabled,
|
||||
'mailboxes' => $enabled ? array_map(fn(Mailbox $mailbox): array => $mailbox->toArray(), $this->lookup->archivedMailboxes()) : [],
|
||||
|
||||
@@ -14,7 +14,6 @@ use Mailcow\Core\AccessDenied;
|
||||
use Mailcow\Core\Context;
|
||||
use Mailcow\Core\Input;
|
||||
use Mailcow\Core\UserError;
|
||||
use PDOException;
|
||||
|
||||
/**
|
||||
* Admin use cases of the archive target. Read-only API keys may read the settings (never password or key).
|
||||
@@ -34,17 +33,15 @@ class SettingsService
|
||||
public function get(): Settings
|
||||
{
|
||||
$this->context->requireAdmin(false);
|
||||
return $this->repo->load();
|
||||
$settings = $this->repo->load();
|
||||
$settings->enabled = $this->state->enabled();
|
||||
return $settings;
|
||||
}
|
||||
|
||||
/** Global switch for internal callers (page templates, mailbox details), no permission check; off while the table is missing */
|
||||
/** Global switch for internal callers (page templates, mailbox details), no permission check */
|
||||
public function enabled(): bool
|
||||
{
|
||||
try {
|
||||
return $this->repo->load()->enabled;
|
||||
} catch (PDOException) {
|
||||
return false;
|
||||
}
|
||||
return $this->state->enabled();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -57,6 +54,7 @@ class SettingsService
|
||||
{
|
||||
$this->context->requireAdmin();
|
||||
$settings = $this->repo->load();
|
||||
$settings->enabled = $this->state->enabled();
|
||||
if (array_key_exists('address', $input)) {
|
||||
$address = strtolower((string)Input::text($input['address']));
|
||||
if (!is_scalar($input['address']) || ($address !== '' && !filter_var($address, FILTER_VALIDATE_EMAIL))) {
|
||||
|
||||
@@ -58,7 +58,7 @@ class StatusService
|
||||
}
|
||||
}
|
||||
return [
|
||||
'enabled' => (int)$settings->enabled,
|
||||
'enabled' => (int)$this->state->enabled(),
|
||||
'configured' => (int)$settings->canDeliver(),
|
||||
'queued' => count($copies),
|
||||
'queued_bytes' => $bytes,
|
||||
|
||||
Reference in new issue
Block a user