Added basic support for ntfy Actions (#1436)

This commit is contained in:
Ivan
2025-11-03 03:37:18 +01:00
committed by GitHub
parent 74d5ad296a
commit 91b6f91094
2 changed files with 25 additions and 0 deletions

View File

@@ -288,6 +288,10 @@ class NotifyNtfy(NotifyBase):
"name": _("Tags"),
"type": "string",
},
"actions": {
"name": _("Actions"),
"type": "string",
},
"mode": {
"name": _("Mode"),
"type": "choice:string",
@@ -319,6 +323,7 @@ class NotifyNtfy(NotifyBase):
email=None,
priority=None,
tags=None,
actions=None,
mode=None,
include_image=True,
avatar_url=None,
@@ -402,6 +407,9 @@ class NotifyNtfy(NotifyBase):
# Any optional tags to attach to the notification
self.__tags = parse_list(tags)
# Action buttons
self.__actions = actions
# Avatar URL
# This allows a user to provide an over-ride to the otherwise
# dynamically generated avatar url images
@@ -597,6 +605,9 @@ class NotifyNtfy(NotifyBase):
if self.__tags:
headers["X-Tags"] = ",".join(self.__tags)
if self.__actions:
headers["X-Actions"] = self.__actions
self.logger.debug(
"ntfy POST URL:"
f" {notify_url} (cert_verify={self.verify_certificate!r})"
@@ -778,6 +789,9 @@ class NotifyNtfy(NotifyBase):
if self.__tags:
params["tags"] = ",".join(self.__tags)
if self.__actions:
params["actions"] = self.__actions
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
# Determine Authentication
@@ -878,6 +892,9 @@ class NotifyNtfy(NotifyBase):
NotifyNtfy.unquote(results["qsd"]["tags"])
)
if "actions" in results["qsd"] and len(results["qsd"]["actions"]):
results["actions"] = NotifyNtfy.unquote(results["qsd"]["actions"])
# Boolean to include an image or not
results["include_image"] = parse_bool(
results["qsd"].get(

View File

@@ -149,6 +149,14 @@ apprise_url_tests = (
"requests_response_text": GOOD_RESPONSE_TEXT,
},
),
# Actions
(
"ntfy://localhost/topic1/?actions=view%2CExample%2Chttp://www.example.com/%3Bview%2CTest%2Chttp://www.test.com/",
{
"instance": NotifyNtfy,
"requests_response_text": GOOD_RESPONSE_TEXT,
},
),
# Delay
(
"ntfy://localhost/topic1/?delay=3600",