notify: force env topic
This commit is contained in:
@@ -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)}
|
||||
|
||||
Reference in New Issue
Block a user