From 34b5d1906474b7fccaa4ee6f949af49c5e052847 Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Thu, 14 May 2026 18:23:35 +0300 Subject: [PATCH] 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) --- backend/main.py | 41 +++++++++++++++++++++++++++++------------ 1 file changed, 29 insertions(+), 12 deletions(-) diff --git a/backend/main.py b/backend/main.py index 523a595..e8564ce 100644 --- a/backend/main.py +++ b/backend/main.py @@ -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