mirror of
https://github.com/Significant-Gravitas/AutoGPT.git
synced 2026-04-08 03:00:28 -04:00
feat(backend): User notification service to send a system alert
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user