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
parent
93ccf42ed6
commit
60b61d64c6
|
@ -317,14 +317,16 @@ async def ntfy(
|
||||||
tags: Optional[str] = None,
|
tags: Optional[str] = None,
|
||||||
attach: Optional[bytes] = None,
|
attach: Optional[bytes] = None,
|
||||||
filename: Optional[str] = None,
|
filename: Optional[str] = None,
|
||||||
|
cache: Optional[bool] = None,
|
||||||
) -> None:
|
) -> None:
|
||||||
assert message or attach
|
assert message or attach
|
||||||
headers = {
|
headers = {}
|
||||||
}
|
|
||||||
if title:
|
if title:
|
||||||
headers['Title'] = title
|
headers['Title'] = title
|
||||||
if tags:
|
if tags:
|
||||||
headers['Tags'] = tags
|
headers['Tags'] = tags
|
||||||
|
if cache is not None:
|
||||||
|
headers['Cache'] = 'yes' if cache else 'no'
|
||||||
url = f'{NTFY_URL}/{topic}'
|
url = f'{NTFY_URL}/{topic}'
|
||||||
client = httpx.AsyncClient()
|
client = httpx.AsyncClient()
|
||||||
if attach:
|
if attach:
|
||||||
|
@ -422,6 +424,6 @@ async def jenkins_notify(request: fastapi.Request) -> None:
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await ntfy(message, 'jenkins', title, tag)
|
await ntfy(message, 'jenkins', title, tag, cache=False)
|
||||||
except httpx.HTTPError:
|
except httpx.HTTPError:
|
||||||
log.exception('Failed to send notification:')
|
log.exception('Failed to send notification:')
|
||||||
|
|
Loading…
Reference in New Issue