Skip to content

AutoGPT is the vision of accessible AI for everyone, to use and to build on. Our mission is to provide the tools, so that you can focus on what matters.

feat(backend): User notification service to send a system alert

Zamil Majdyd2bf0af3cd89
diff --git a/autogpt_platform/backend/backend/executor/scheduler.py b/autogpt_platform/backend/backend/executor/scheduler.py
index 05ce759b3b..6b9008d4cc 100644
--- a/autogpt_platform/backend/backend/executor/scheduler.py
+++ b/autogpt_platform/backend/backend/executor/scheduler.py
@@ -20,7 +20,7 @@ from backend.data.block import BlockInput
from backend.data.execution import ExecutionStatus
from backend.executor import utils as execution_utils
from backend.notifications.notifications import NotificationManagerClient
-from backend.util.metrics import discord_send_alert, sentry_capture_error
+from backend.util.metrics import sentry_capture_error
from backend.util.service import (
AppService,
AppServiceClient,
@@ -112,7 +112,7 @@ def report_late_executions() -> str:
)
msg = str(error)
sentry_capture_error(error)
- discord_send_alert(msg)
+ get_notification_client().discord_system_alert(msg)
return msg
diff --git a/autogpt_platform/backend/backend/notifications/notifications.py b/autogpt_platform/backend/backend/notifications/notifications.py
index a697269b2d..4bee454cba 100644
--- a/autogpt_platform/backend/backend/notifications/notifications.py
+++ b/autogpt_platform/backend/backend/notifications/notifications.py
@@ -37,6 +37,7 @@ from backend.data.rabbitmq import (
)
from backend.data.user import generate_unsubscribe_link
from backend.notifications.email import EmailSender
+from backend.util.metrics import discord_send_alert
from backend.util.service import (
AppService,
AppServiceClient,
@@ -384,6 +385,10 @@ class NotificationManager(AppService):
"timestamp": datetime.now(tz=timezone.utc).isoformat(),
}
+ @expose
+ def discord_system_alert(self, content: str):
+ discord_send_alert(content)
+
def _queue_scheduled_notification(self, event: SummaryParamsEventModel):
"""Queue a scheduled notification - exposed method for other services to call"""
try:
@@ -785,3 +790,4 @@ class NotificationManagerClient(AppServiceClient):
process_existing_batches = NotificationManager.process_existing_batches
queue_weekly_summary = NotificationManager.queue_weekly_summary
+ discord_system_alert = NotificationManager.discord_system_alert