feat: implement global autoresponder plugin

This commit is contained in:
Marek Miklewicz
2026-06-02 19:19:00 +02:00
commit 6f989af278
62 changed files with 2018 additions and 0 deletions
+18
View File
@@ -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);
};