From 60b61d64c652e1bcd6ad6b2ee488c7cebdeae274 Mon Sep 17 00:00:00 2001 From: "Dustin C. Hatch" Date: Tue, 16 Jan 2024 17:33:50 -0600 Subject: [PATCH] Do not cache ntfy notifications from Jenkins These notifications are really only useful for real-time monitoring of builds starting and finishing. There's no reason to cache them for clients who were not connected when they were originally sent. --- dch_webhooks.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dch_webhooks.py b/dch_webhooks.py index 69816b0..3b9037b 100644 --- a/dch_webhooks.py +++ b/dch_webhooks.py @@ -317,14 +317,16 @@ async def ntfy( tags: Optional[str] = None, attach: Optional[bytes] = None, filename: Optional[str] = None, + cache: Optional[bool] = None, ) -> None: assert message or attach - headers = { - } + headers = {} if title: headers['Title'] = title if tags: headers['Tags'] = tags + if cache is not None: + headers['Cache'] = 'yes' if cache else 'no' url = f'{NTFY_URL}/{topic}' client = httpx.AsyncClient() if attach: @@ -422,6 +424,6 @@ async def jenkins_notify(request: fastapi.Request) -> None: return try: - await ntfy(message, 'jenkins', title, tag) + await ntfy(message, 'jenkins', title, tag, cache=False) except httpx.HTTPError: log.exception('Failed to send notification:')