adding telegram notifications
Deploy / deploy (push) Successful in 8s

This commit is contained in:
2026-05-06 18:25:15 +02:00
parent 08df9bfe5c
commit e203aac2f5
5 changed files with 177 additions and 1 deletions
+21
View File
@@ -84,6 +84,11 @@ class Router
$path === '/config/allowed_tokens' && $method === 'PUT'
=> $this->updateAllowedTokens(),
$path === '/config/telegram' && $method === 'GET'
=> $this->getTelegramConfig(),
$path === '/config/telegram' && $method === 'PUT'
=> $this->updateTelegramConfig(),
default => throw new \RuntimeException('Not found', 404),
};
@@ -271,4 +276,20 @@ class Router
return ['status' => 'ingested', 'line' => substr($line, 0, 100)];
}
private function getTelegramConfig(): array
{
return [
'bot_token' => $this->repo->getConfig('telegram_bot_token', ''),
'chat_id' => $this->repo->getConfig('telegram_chat_id', ''),
];
}
private function updateTelegramConfig(): array
{
$body = json_decode(file_get_contents('php://input'), true);
$this->repo->setConfig('telegram_bot_token', $body['bot_token'] ?? '');
$this->repo->setConfig('telegram_chat_id', $body['chat_id'] ?? '');
return $this->getTelegramConfig();
}
}