feat: implement global autoresponder plugin
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
<?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);
|
||||
};
|
||||
Reference in New Issue
Block a user