fix: match directadmin vacation controls

This commit is contained in:
Marek Miklewicz
2026-06-03 09:21:51 +02:00
parent 0617798821
commit 9174d62706
12 changed files with 176 additions and 53 deletions
+18 -2
View File
@@ -5,6 +5,8 @@ final class RuleValidator
{
/** @var array<string,int> */
private const REPLY_FREQUENCIES = [
'1' => 1,
'10' => 10,
'30' => 30,
'60' => 60,
'120' => 120,
@@ -12,7 +14,18 @@ final class RuleValidator
'720' => 720,
'1440' => 1440,
'2880' => 2880,
'4320' => 4320,
'5760' => 5760,
'7200' => 7200,
'8640' => 8640,
'10080' => 10080,
'11520' => 11520,
'12960' => 12960,
'14400' => 14400,
'15840' => 15840,
'17280' => 17280,
'18720' => 18720,
'20160' => 20160,
];
/** @param array<string,mixed> $input @return array<string,mixed> */
@@ -45,7 +58,7 @@ final class RuleValidator
if ($endTs <= $startTs) {
throw new InvalidArgumentException('Data zakończenia musi być późniejsza niż data rozpoczęcia.');
}
[$replyEveryMessage, $repeatMinutes] = self::parseReplyFrequency((string)($input['reply_frequency'] ?? '1440'));
[$replyEveryMessage, $repeatMinutes] = self::parseReplyFrequency((string)($input['reply_frequency'] ?? '1440'), $settings);
return [
'subject_prefix' => $subjectPrefix,
@@ -64,10 +77,13 @@ final class RuleValidator
}
/** @return array{0:bool,1:int} */
private static function parseReplyFrequency(string $value): array
private static function parseReplyFrequency(string $value, Settings $settings): array
{
$value = trim(strtolower($value));
if ($value === 'every') {
if ($settings->backendMode() === 'da') {
throw new InvalidArgumentException('Częstość odpowiedzi jest nieprawidłowa.');
}
return [true, 0];
}
if (isset(self::REPLY_FREQUENCIES[$value])) {