+8
-1
@@ -3,6 +3,7 @@
|
||||
namespace Jakach\Logging\Api;
|
||||
|
||||
use Jakach\Logging\Model\{LogSourceType, AlertStatus};
|
||||
use Jakach\Logging\Notifier\TelegramNotifier;
|
||||
use Jakach\Logging\Storage\{Database, Repository};
|
||||
use Jakach\Logging\RuleEngine\Engine;
|
||||
|
||||
@@ -11,6 +12,7 @@ class Router
|
||||
private Repository $repo;
|
||||
private AuthMiddleware $auth;
|
||||
private Engine $engine;
|
||||
private TelegramNotifier $telegram;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
@@ -18,6 +20,7 @@ class Router
|
||||
$this->repo = new Repository($db);
|
||||
$this->auth = new AuthMiddleware($this->repo);
|
||||
$this->engine = new Engine($this->repo);
|
||||
$this->telegram = new TelegramNotifier($this->repo);
|
||||
}
|
||||
|
||||
public function handle(): void
|
||||
@@ -272,7 +275,11 @@ class Router
|
||||
return ['error' => 'Missing "line" field'];
|
||||
}
|
||||
|
||||
$this->engine->evaluate($line, null);
|
||||
$alert = $this->engine->evaluate($line, null);
|
||||
|
||||
if ($alert !== null) {
|
||||
$this->telegram->send($alert);
|
||||
}
|
||||
|
||||
return ['status' => 'ingested', 'line' => substr($line, 0, 100)];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user