From 06698cb54e7f7fd00accb60b2da3d7e70cee0c5e Mon Sep 17 00:00:00 2001 From: arabcoders Date: Sun, 19 Oct 2025 17:51:58 +0300 Subject: [PATCH] Fix possible issue with apprise notification. --- app/library/Notifications.py | 9 ++++++--- app/tests/test_notifications.py | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/library/Notifications.py b/app/library/Notifications.py index 490ac303..0508da7a 100644 --- a/app/library/Notifications.py +++ b/app/library/Notifications.py @@ -438,7 +438,7 @@ class Notification(metaclass=Singleton): import apprise try: - notify = apprise.Apprise() + notify = apprise.Apprise(debug=self._debug) apr_config = Path(Config.get_instance().apprise_config) if apr_config.exists(): apprise_config = notify.AppriseConfig() @@ -448,11 +448,14 @@ class Notification(metaclass=Singleton): for t in target: notify.add(t.request.url) - notify.notify( + status = await notify.async_notify( body=ev.message or json.dumps(ev.serialize(), sort_keys=False, ensure_ascii=False), title=ev.title or f"YTPTube Event: {ev.event}", - notify_type=ev.event, ) + + if not status: + msg = "Apprise failed to send notification." + raise RuntimeError(msg) # noqa: TRY301 except Exception as e: LOG.exception(e) LOG.error(f"Error sending Apprise notification: {e!s}") diff --git a/app/tests/test_notifications.py b/app/tests/test_notifications.py index 8d59b1a6..998b07bd 100644 --- a/app/tests/test_notifications.py +++ b/app/tests/test_notifications.py @@ -812,6 +812,8 @@ class TestNotification: # Mock apprise import mock_apprise = Mock() mock_notify = Mock() + # Mock async_notify as an AsyncMock that returns True + mock_notify.async_notify = AsyncMock(return_value=True) mock_apprise.Apprise.return_value = mock_notify mock_import.return_value = mock_apprise