mirror of
https://github.com/caronc/apprise.git
synced 2025-12-15 10:04:06 +08:00
Added basic support for ntfy Actions (#1436)
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user