Fix hina_invitation template: auto-correct body parameters on startup to match what's being sent (7 params: contact_name, groom_name, bride_name, venue, event_date, event_time, guest_link)
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
dvirlabs 2026-05-14 18:23:35 +03:00
parent a8b6cd2e17
commit 34b5d19064

View File

@ -74,9 +74,29 @@ def _fix_template_parameters():
import json
db = SessionLocal()
try:
# No built-in template fixes needed currently
# hina_invitation is now user-managed only (not built-in)
pass
# Fix hina_invitation template if it exists
template = db.query(models.WhatsAppTemplate).filter(
(models.WhatsAppTemplate.template_key == 'hina_invitation') |
(models.WhatsAppTemplate.meta_name == 'hina_invitation')
).first()
if template:
# Correct body parameters to match what send_wedding_invitation_bulk sends
correct_params = [
"contact_name",
"groom_name",
"bride_name",
"venue",
"event_date",
"event_time",
"guest_link"
]
current_params = json.loads(template.body_params or "[]")
if current_params != correct_params:
template.body_params = json.dumps(correct_params)
db.commit()
print(f"[startup] Fixed hina_invitation template: {current_params}{correct_params}")
except Exception as e:
print(f"[startup] Template fix warning: {e}")
finally:
@ -2036,18 +2056,15 @@ async def fix_templates(db: Session = Depends(get_db)):
"message": "hina_invitation template not found in database"
}
# Correct body parameters for hina_invitation
# Correct body parameters to match what send_wedding_invitation_bulk sends
correct_params = [
"contact_name",
"event_date",
"event_date_day",
"venue",
"location",
"reception_time",
"ceremony_time",
"dinner_time",
"groom_name",
"bride_name",
"groom_name"
"venue",
"event_date",
"event_time",
"guest_link"
]
old_params = template.body_params