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
+14
View File
@@ -0,0 +1,14 @@
<?php
declare(strict_types=1);
return static function (AppContext $ctx): void {
$ctx->requirePost();
$id = $ctx->post('id');
$ctx->requireCsrf('toggle:' . $id);
$rule = $ctx->rules->find($ctx->daUser->username(), $id);
if ($rule === null) {
throw new RuntimeException('Rule not found');
}
$ctx->rules->update($ctx->daUser->username(), $id, ['enabled' => empty($rule['enabled'])]);
Http::redirect($ctx->url('index.html', ['status' => 'toggled']));
};