1
0
Fork 0

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.
master
Dustin 2024-01-16 17:33:50 -06:00
parent 93ccf42ed6
commit 60b61d64c6
1 changed files with 5 additions and 3 deletions

View File

@ -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:')