feat: add icon field support for bark plugin (#1393)

pull/1395/head
HerbertGao 2025-08-17 01:00:57 +08:00 committed by GitHub
parent 666f50457c
commit 92d5d7cc8a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 35 additions and 1 deletions

View File

@ -209,6 +209,10 @@ class NotifyBark(NotifyBase):
"default": True,
"map_to": "include_image",
},
"icon": {
"name": _("Icon URL"),
"type": "string",
},
},
)
@ -223,6 +227,7 @@ class NotifyBark(NotifyBase):
click=None,
badge=None,
volume=None,
icon=None,
**kwargs,
):
"""Initialize Notify Bark Object."""
@ -301,6 +306,9 @@ class NotifyBark(NotifyBase):
volume,
)
# Icon URL
self.icon = icon if isinstance(icon, str) else None
# Level
self.level = (
None
@ -353,7 +361,10 @@ class NotifyBark(NotifyBase):
None if not self.include_image else self.image_url(notify_type)
)
if image_url:
# Use custom icon if provided, otherwise use default image
if self.icon:
payload["icon"] = self.icon
elif image_url:
payload["icon"] = image_url
if self.sound:
@ -488,6 +499,9 @@ class NotifyBark(NotifyBase):
if self.group:
params["group"] = self.group
if self.icon:
params["icon"] = self.icon
# Extend our parameters
params.update(self.url_parameters(privacy=privacy, *args, **kwargs))
@ -588,4 +602,10 @@ class NotifyBark(NotifyBase):
results["qsd"].get("image", True)
)
# Icon URL
if "icon" in results["qsd"] and results["qsd"]["icon"]:
results["icon"] = NotifyBark.unquote(
results["qsd"]["icon"].strip()
)
return results

View File

@ -240,6 +240,20 @@ apprise_url_tests = (
"test_requests_exceptions": True,
},
),
(
"bark://192.168.0.6:8081/device_key/?icon=https://example.com/icon.png",
{
# set custom icon
"instance": NotifyBark,
},
),
(
"bark://192.168.0.6:8081/device_key/?icon=https://example.com/icon.png&image=no",
{
# set custom icon and disable default image
"instance": NotifyBark,
},
),
)