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
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
a8b6cd2e17
commit
34b5d19064
@ -74,9 +74,29 @@ def _fix_template_parameters():
|
|||||||
import json
|
import json
|
||||||
db = SessionLocal()
|
db = SessionLocal()
|
||||||
try:
|
try:
|
||||||
# No built-in template fixes needed currently
|
# Fix hina_invitation template if it exists
|
||||||
# hina_invitation is now user-managed only (not built-in)
|
template = db.query(models.WhatsAppTemplate).filter(
|
||||||
pass
|
(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:
|
except Exception as e:
|
||||||
print(f"[startup] Template fix warning: {e}")
|
print(f"[startup] Template fix warning: {e}")
|
||||||
finally:
|
finally:
|
||||||
@ -2036,18 +2056,15 @@ async def fix_templates(db: Session = Depends(get_db)):
|
|||||||
"message": "hina_invitation template not found in database"
|
"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 = [
|
correct_params = [
|
||||||
"contact_name",
|
"contact_name",
|
||||||
"event_date",
|
"groom_name",
|
||||||
"event_date_day",
|
|
||||||
"venue",
|
|
||||||
"location",
|
|
||||||
"reception_time",
|
|
||||||
"ceremony_time",
|
|
||||||
"dinner_time",
|
|
||||||
"bride_name",
|
"bride_name",
|
||||||
"groom_name"
|
"venue",
|
||||||
|
"event_date",
|
||||||
|
"event_time",
|
||||||
|
"guest_link"
|
||||||
]
|
]
|
||||||
|
|
||||||
old_params = template.body_params
|
old_params = template.body_params
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user