1
0
forked from erp-dev/erp

feat: message-api for mission via wecomm agent

This commit is contained in:
2026-05-14 09:30:38 +08:00
parent 9359013b4c
commit f409f2e6ee
38 changed files with 2085 additions and 49 deletions

View File

@@ -1,5 +1,6 @@
import logging
from django.conf import settings
from django.db.models import Case, IntegerField, Q, Value, When
from django.template.loader import render_to_string
@@ -10,7 +11,15 @@ logger = logging.getLogger(__name__)
def render_notification_content(*, notifier: Notifier, payload: dict) -> str:
content = render_to_string(notifier.get_template_name(), payload or {}).strip()
context = {
**(payload or {}),
"notifier_config": notifier.config or {},
"notifier_config_url": notifier.get_config_value("url", "") or "",
"notifier_config_image_url": notifier.get_config_value("image_url", "") or "",
"default_news_image_url": getattr(settings, "MESSAGE_API_DEFAULT_NEWS_IMAGE_URL", "") or "",
"notifier": notifier,
}
content = render_to_string(notifier.get_template_name(), context).strip()
if not content:
raise ValueError("通知模板渲染结果不能为空")
return content