mirror of
https://git.vectorsigma.ru/public/tubearchivist.git
synced 2026-08-05 03:59:24 +00:00
Add test notification button (#996)
* Add api to test notifications before you save * Add button to UI * Inspect apprise logs to get errors * Better formatting around errors coming back from the test notification endpoint * Use apprise's built in log capture * Instruct the user to get error from container log instead of intercepting and parsing apprise logs * refac move to test method on notification class --------- Co-authored-by: Simon <simobilleter@gmail.com>
This commit is contained in:
@@ -32,6 +32,38 @@ class Notifications:
|
||||
|
||||
apobj.notify(body=body, title=title)
|
||||
|
||||
def test(self, url) -> tuple[bool, str]:
|
||||
"""send test notification"""
|
||||
try:
|
||||
apobj = apprise.Apprise()
|
||||
|
||||
if not apobj.add(url):
|
||||
success = False
|
||||
message = f"Invalid notification URL format: {url}"
|
||||
return success, message
|
||||
|
||||
title = f"[TA] {self.task_name} process ended with SUCCESS"
|
||||
body = "This is a test notification. Task completed successfully."
|
||||
|
||||
result = apobj.notify(body=body, title=title)
|
||||
|
||||
if result:
|
||||
success = True
|
||||
message = "Test notification sent successfully"
|
||||
return success, message
|
||||
|
||||
success = False
|
||||
message = (
|
||||
"Notification failed. "
|
||||
"Please check container logs for more information."
|
||||
)
|
||||
return success, message
|
||||
|
||||
except Exception as err: # pylint: disable=broad-exception-caught
|
||||
success = False
|
||||
message = f"Notification error: {str(err)}"
|
||||
return success, message
|
||||
|
||||
def _build_message(
|
||||
self, task_id: str, task_title: str
|
||||
) -> tuple[str, str | None]:
|
||||
|
||||
Reference in New Issue
Block a user