feat: derive autoresponder schedule from backend
This commit is contained in:
@@ -51,7 +51,7 @@ final class Settings
|
||||
'DEFAULT_PLUGIN_LANGUAGE' => 'en',
|
||||
'DEFAULT_ENABLE' => 'true',
|
||||
'GLOBAL_AUTORESPONDER_TIMEZONE' => 'Europe/Warsaw',
|
||||
'GLOBAL_AUTORESPONDER_SCHEDULE_MODE' => 'exact_hour',
|
||||
'GLOBAL_AUTORESPONDER_BACKEND' => 'da',
|
||||
'GLOBAL_AUTORESPONDER_REPLY_EVERY_MESSAGE' => 'false',
|
||||
'GLOBAL_AUTORESPONDER_REPEAT_MINUTES' => '1440',
|
||||
'GLOBAL_AUTORESPONDER_DYNAMIC_MAILBOX_SCOPE' => 'true',
|
||||
@@ -93,9 +93,14 @@ final class Settings
|
||||
return $this->getString('GLOBAL_AUTORESPONDER_TIMEZONE', 'Europe/Warsaw');
|
||||
}
|
||||
|
||||
public function backendMode(): string
|
||||
{
|
||||
return $this->getString('GLOBAL_AUTORESPONDER_BACKEND', 'da');
|
||||
}
|
||||
|
||||
public function scheduleMode(): string
|
||||
{
|
||||
return $this->getString('GLOBAL_AUTORESPONDER_SCHEDULE_MODE', 'exact_hour');
|
||||
return $this->backendMode() === 'da' ? 'directadmin_period' : 'exact_hour';
|
||||
}
|
||||
|
||||
public function replyEveryMessage(): bool
|
||||
@@ -148,8 +153,8 @@ final class Settings
|
||||
} catch (Throwable) {
|
||||
throw new InvalidArgumentException('Invalid timezone: ' . $this->timezone());
|
||||
}
|
||||
if (!in_array($this->scheduleMode(), ['exact_hour', 'directadmin_period'], true)) {
|
||||
throw new InvalidArgumentException('Invalid schedule mode: ' . $this->scheduleMode());
|
||||
if (!in_array($this->backendMode(), ['da', 'exim'], true)) {
|
||||
throw new InvalidArgumentException('Invalid backend mode: ' . $this->backendMode());
|
||||
}
|
||||
if ($this->repeatMinutes() < 0) {
|
||||
throw new InvalidArgumentException('Invalid repeat minutes');
|
||||
|
||||
Reference in New Issue
Block a user