notify: force env topic

This commit is contained in:
chelsea
2025-11-11 23:29:25 -06:00
parent 2a05a80cc2
commit b89e1b196b
3 changed files with 13 additions and 7 deletions

View File

@@ -35,9 +35,7 @@ class NotificationDispatcher:
def sendReminder(userId: str, reminder: Dict[str, Any]):
metadata = reminder.get("metadata") or {}
actualUser = userId or reminder.get("user") or metadata.get("user") or "user"
topic = reminder.get("topic") or metadata.get("topic")
if not topic:
topic = ntfyTopicTemplate.format(userId=actualUser)
topic = NotificationDispatcher.buildTopic(actualUser)
url = NotificationDispatcher.buildTopicUrl(topic)
if not url:
return
@@ -76,6 +74,16 @@ class NotificationDispatcher:
topicSlug = topic.lstrip("/")
return f"{base}/{topicSlug}"
@staticmethod
def buildTopic(actualUser: str) -> str:
template = ntfyTopicTemplate or ""
if not template:
return ""
try:
return template.format(userId=actualUser)
except (KeyError, IndexError, ValueError):
return template
@staticmethod
def buildHeaders(message_text: str) -> Dict[str, str]:
headers = {"Title": NotificationDispatcher.buildTitleHeader(message_text)}