19 lines
629 B
PHP
19 lines
629 B
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
return static function (AppContext $ctx): void {
|
|
$errors = [];
|
|
if (Http::isPost()) {
|
|
try {
|
|
$ctx->requireCsrf('create');
|
|
$input = normalize_rule_post($_POST);
|
|
$rule = RuleValidator::validate($input, $ctx->settings);
|
|
$ctx->rules->create($ctx->daUser->username(), $rule);
|
|
Http::redirect($ctx->url('index.html', ['status' => 'created']));
|
|
} catch (Throwable $e) {
|
|
$errors[] = $e->getMessage();
|
|
}
|
|
}
|
|
$ctx->render('Add autoresponder', render_rule_form($ctx, 'create', null), [], $errors);
|
|
};
|