@@ -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();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user