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
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
This commit is contained in:
parent
7f50aec444
commit
6971726fc9
@ -34,5 +34,27 @@
|
|||||||
"button_index": 0,
|
"button_index": 0,
|
||||||
"param_key": "event_id"
|
"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": ""
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -81,25 +81,38 @@ def _fix_template_parameters():
|
|||||||
|
|
||||||
if template:
|
if template:
|
||||||
# Expected correct parameters for hina_invitation
|
# Expected correct parameters for hina_invitation
|
||||||
# Body {{1}} = contact_name (guest's name)
|
# Body {{1}} = contact_name (guest's name in greeting)
|
||||||
# Button {{1}} = event_id (sent as separate button parameter)
|
# Button {{1}} = event_id (sent as separate button parameter in URL)
|
||||||
expected_params = ["contact_name"]
|
expected_params = ["contact_name"]
|
||||||
|
expected_button_param_key = "event_id"
|
||||||
|
|
||||||
try:
|
try:
|
||||||
current_params = json.loads(template.body_params)
|
current_params = json.loads(template.body_params)
|
||||||
except:
|
except:
|
||||||
current_params = []
|
current_params = []
|
||||||
|
|
||||||
# Check if parameters need fixing
|
needs_fixing = False
|
||||||
|
|
||||||
|
# Check if body parameters need fixing
|
||||||
if current_params != expected_params:
|
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" Old: {current_params}")
|
||||||
print(f" New: {expected_params}")
|
print(f" New: {expected_params}")
|
||||||
|
|
||||||
template.body_params = json.dumps(expected_params)
|
template.body_params = json.dumps(expected_params)
|
||||||
if not template.header_type:
|
needs_fixing = True
|
||||||
template.header_type = "IMAGE"
|
|
||||||
|
|
||||||
|
# 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()
|
db.commit()
|
||||||
print(f" ✓ Template fixed!")
|
print(f" ✓ Template fixed!")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
@ -2017,9 +2030,7 @@ async def test_whatsapp_send(
|
|||||||
result = await service.send_by_template_key(
|
result = await service.send_by_template_key(
|
||||||
template_key=template_key,
|
template_key=template_key,
|
||||||
to_phone=phone,
|
to_phone=phone,
|
||||||
params=params,
|
params=params
|
||||||
event_id=params.get("event_id"),
|
|
||||||
guest_id=None,
|
|
||||||
)
|
)
|
||||||
|
|
||||||
logger.info(f"[TEST] Message sent successfully: {result}")
|
logger.info(f"[TEST] Message sent successfully: {result}")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user