Fix template
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
dvirlabs 2026-05-14 15:50:08 +03:00
parent a70a201222
commit 66e5f3bf70

View File

@ -45,6 +45,13 @@ def load_custom_templates(db: Session) -> Dict[str, Dict[str, Any]]:
templates = db.query(WhatsAppTemplate).all()
result = {}
for t in templates:
# Determine button_param_key:
# - If button_url contains {{1}}, default to "event_id"
# - Otherwise leave empty (static URL buttons don't need params)
button_param_key = ""
if t.button_url and "{{1}}" in t.button_url:
button_param_key = "event_id"
result[t.template_key] = {
"meta_name": t.meta_name,
"language_code": t.language_code,
@ -59,7 +66,7 @@ def load_custom_templates(db: Session) -> Dict[str, Dict[str, Any]]:
"button_type": t.button_type,
"button_text": t.button_text,
"button_url": t.button_url,
"button_param_key": t.button_url, # backward compat
"button_param_key": button_param_key, # Derived from URL pattern
"fallbacks": json.loads(t.fallbacks),
"guest_name_key": "",
}