mirror of
https://github.com/rommapp/romm.git
synced 2026-12-02 18:18:47 +01:00
Each user can add channels that forward their notifications: a webhook posting RomM's JSON (optionally HMAC-signed), a Discord embed or an ntfy message, or an email address confirmed with a code. A channel filters by minimum level and by topic, and every stored notification that passes goes out in its own RQ job, retried three times; ten failures in a row turn the channel off and tell its owner. Channel configs are sealed with a key derived from ROMM_AUTH_SECRET_KEY, since a webhook URL carries its own token. Only an admin's webhooks may reach private addresses; everyone else's go through the SSRF guard. Email goes out over the SMTP_* settings, which the heartbeat reports as NOTIFICATIONS.EMAIL_ENABLED. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
32 lines
967 B
Python
32 lines
967 B
Python
from datetime import datetime, timezone
|
|
from typing import Any
|
|
|
|
from endpoints.responses.notification import NotificationActorSchema, NotificationSchema
|
|
from models.notification import NotificationKind, NotificationLevel
|
|
|
|
|
|
def make_notification(**overrides: Any) -> NotificationSchema:
|
|
fields: dict[str, Any] = {
|
|
"id": 7,
|
|
"kind": NotificationKind.CUSTOM,
|
|
"level": NotificationLevel.INFO,
|
|
"title": "Maintenance tonight",
|
|
"body": "RomM restarts at 23:00",
|
|
"link": "/platforms",
|
|
"icon": None,
|
|
"data": {},
|
|
"actor": None,
|
|
"read_at": None,
|
|
"created_at": datetime(2026, 9, 23, 12, tzinfo=timezone.utc),
|
|
}
|
|
return NotificationSchema(**{**fields, **overrides})
|
|
|
|
|
|
def make_actor() -> NotificationActorSchema:
|
|
return NotificationActorSchema(
|
|
id=1,
|
|
username="admin",
|
|
avatar_path="",
|
|
updated_at=datetime(2026, 9, 23, tzinfo=timezone.utc),
|
|
)
|