|
|
@@ -6,6 +6,8 @@ namespace App;
|
|
|
|
|
|
final class AlertService
|
|
|
{
|
|
|
+ private const MAX_EVENTS = 15;
|
|
|
+
|
|
|
private JsonFile $logStorage;
|
|
|
|
|
|
public function __construct(
|
|
|
@@ -65,14 +67,14 @@ final class AlertService
|
|
|
'payload' => $payload,
|
|
|
'deliveries' => $deliveryResults,
|
|
|
]);
|
|
|
- $log['events'] = array_slice($events, 0, 200);
|
|
|
+ $log['events'] = array_slice($events, 0, self::MAX_EVENTS);
|
|
|
$this->logStorage->write($log);
|
|
|
}
|
|
|
|
|
|
- public function getRecentEvents(int $limit = 25): array
|
|
|
+ public function getRecentEvents(int $limit = self::MAX_EVENTS): array
|
|
|
{
|
|
|
$log = $this->logStorage->read();
|
|
|
- return array_slice($log['events'] ?? [], 0, $limit);
|
|
|
+ return array_slice($log['events'] ?? [], 0, min($limit, self::MAX_EVENTS));
|
|
|
}
|
|
|
|
|
|
private function sendWebhooks(array $slot, array $payload): array
|