Fix hina_invitation: body param (contact_name) + button param (event_id) with exact body text
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
dvirlabs 2026-05-14 09:26:17 +03:00
parent 7f50aec444
commit 6971726fc9
2 changed files with 44 additions and 11 deletions

View File

@ -34,5 +34,27 @@
"button_index": 0,
"param_key": "event_id"
}
},
"hina_invitation": {
"meta_name": "hina_invitation",
"language_code": "he",
"friendly_name": "הזמנה לחינה",
"description": "הזמנה לאירוע חינה עם שם אישי וקישור דינמי",
"header_type": "TEXT",
"header_text": "",
"header_params": [],
"body_text": "היי {{1}} 🤍\n\nמוזמנת לחינה שלנו!\n\nרק בנות ✨\nארוחה חלבית\n\nנשמח לאישור הגעה בקישור המצורף 🙏",
"body_params": [
"contact_name"
],
"button_type": "URL",
"button_url": "https://invy.dvirlabs.com/guest/{{1}}",
"button_text": "הצבע על הזמנה",
"button_param_key": "event_id",
"fallbacks": {
"contact_name": "חבר",
"event_id": "event-id"
},
"guest_name_key": ""
}
}

View File

@ -81,25 +81,38 @@ def _fix_template_parameters():
if template:
# Expected correct parameters for hina_invitation
# Body {{1}} = contact_name (guest's name)
# Button {{1}} = event_id (sent as separate button parameter)
# Body {{1}} = contact_name (guest's name in greeting)
# Button {{1}} = event_id (sent as separate button parameter in URL)
expected_params = ["contact_name"]
expected_button_param_key = "event_id"
try:
current_params = json.loads(template.body_params)
except:
current_params = []
# Check if parameters need fixing
needs_fixing = False
# Check if body parameters need fixing
if current_params != expected_params:
print(f"[startup] Fixing hina_invitation template parameters...")
print(f"[startup] Fixing hina_invitation template body parameters...")
print(f" Old: {current_params}")
print(f" New: {expected_params}")
template.body_params = json.dumps(expected_params)
if not template.header_type:
template.header_type = "IMAGE"
needs_fixing = True
# Check if button parameter key is set correctly
if not template.button_param_key or template.button_param_key != expected_button_param_key:
print(f"[startup] Setting hina_invitation button parameter...")
template.button_param_key = expected_button_param_key
needs_fixing = True
# Check header type
if not template.header_type:
template.header_type = "TEXT"
needs_fixing = True
if needs_fixing:
db.commit()
print(f" ✓ Template fixed!")
except Exception as e:
@ -2017,9 +2030,7 @@ async def test_whatsapp_send(
result = await service.send_by_template_key(
template_key=template_key,
to_phone=phone,
params=params,
event_id=params.get("event_id"),
guest_id=None,
params=params
)
logger.info(f"[TEST] Message sent successfully: {result}")