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
+28
View File
@@ -0,0 +1,28 @@
<?php
declare(strict_types=1);
final class AuditLog
{
public function __construct(private string $path = Settings::AUDIT_LOG)
{
}
/** @param array<string,string|int|bool> $fields */
public function record(string $action, string $user, array $fields = []): void
{
$dir = dirname($this->path);
if (!is_dir($dir)) {
@mkdir($dir, 0700, true);
}
unset($fields['body']);
$line = json_encode([
'ts' => date('c'),
'action' => $action,
'user' => $user,
'fields' => $fields,
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
if ($line !== false) {
@file_put_contents($this->path, $line . "\n", FILE_APPEND | LOCK_EX);
}
}
}