Improve timestamp handling and event navigation

This commit is contained in:
Stanislav Rossovskii
2026-05-27 11:01:27 +04:00
parent edc51e9c59
commit 71f0035b0b
37 changed files with 485 additions and 109 deletions

View File

@@ -3,6 +3,7 @@ from __future__ import annotations
import httpx
from ...redaction import redact_dict
from ...timeutil import payload_with_display_times
from .base import DeliveryResult
from .http import classify_response
@@ -10,16 +11,22 @@ from .http import classify_response
class WebhookNotifier:
name = "webhook"
def __init__(self, client: httpx.AsyncClient, url: str, token: str = "") -> None:
def __init__(
self, client: httpx.AsyncClient, url: str, token: str = "", time_zone: str = "UTC"
) -> None:
self._client = client
self._url = url
self._token = token
self._time_zone = time_zone
async def deliver(self, event_type: str, payload: dict) -> DeliveryResult:
headers = {"Content-Type": "application/json"}
if self._token:
headers["Authorization"] = f"Bearer {self._token}"
body = {"event_type": event_type, "incident": redact_dict(payload)}
body = {
"event_type": event_type,
"incident": redact_dict(payload_with_display_times(payload, self._time_zone)),
}
try:
resp = await self._client.post(self._url, json=body, headers=headers)
except httpx.HTTPError as exc: