Fix: 1) Improve SSL/TLS handling for Meta API 2) hina_invitation has body param (contact_name) and button param (event_id)
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
df8970f101
commit
92b35d297d
@ -81,9 +81,9 @@ def _fix_template_parameters():
|
|||||||
|
|
||||||
if template:
|
if template:
|
||||||
# Expected correct parameters for hina_invitation
|
# Expected correct parameters for hina_invitation
|
||||||
# hina_invitation has NO body parameters (body is static in Meta)
|
# Body {{1}} = contact_name (guest's name)
|
||||||
# Only has button parameter: event_id
|
# Button {{1}} = event_id (sent as separate button parameter)
|
||||||
expected_params = []
|
expected_params = ["contact_name"]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
current_params = json.loads(template.body_params)
|
current_params = json.loads(template.body_params)
|
||||||
@ -2001,12 +2001,15 @@ async def test_whatsapp_send(
|
|||||||
|
|
||||||
service = get_whatsapp_service(db)
|
service = get_whatsapp_service(db)
|
||||||
|
|
||||||
# hina_invitation template has no body parameters - only button parameter
|
# hina_invitation template needs both parameters:
|
||||||
|
# - contact_name: for body {{1}} (guest's name)
|
||||||
|
# - event_id: for button {{1}} (dynamic URL)
|
||||||
params = {
|
params = {
|
||||||
|
"contact_name": "Test",
|
||||||
"event_id": "test-event-123"
|
"event_id": "test-event-123"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use hina_invitation template (static body, dynamic button URL)
|
# Use hina_invitation template
|
||||||
template_key = "hina_invitation"
|
template_key = "hina_invitation"
|
||||||
|
|
||||||
result = await service.send_by_template_key(
|
result = await service.send_by_template_key(
|
||||||
|
|||||||
@ -17,11 +17,16 @@ logger = logging.getLogger(__name__)
|
|||||||
async def create_http_client() -> httpx.AsyncClient:
|
async def create_http_client() -> httpx.AsyncClient:
|
||||||
"""
|
"""
|
||||||
Create an httpx client with proper certificate verification.
|
Create an httpx client with proper certificate verification.
|
||||||
Uses certifi for CA bundle and lets httpx handle SSL/TLS negotiation.
|
Uses certifi for CA bundle and explicit TLS 1.2+ negotiation.
|
||||||
"""
|
"""
|
||||||
# Let httpx use certifi's CA bundle - simpler and more reliable
|
import ssl
|
||||||
|
# Create a default SSL context that prefers TLS 1.2 and higher
|
||||||
|
ssl_context = ssl.create_default_context(cafile=certifi.where())
|
||||||
|
ssl_context.minimum_version = ssl.TLSVersion.TLSv1_2
|
||||||
|
ssl_context.check_hostname = True
|
||||||
|
|
||||||
return httpx.AsyncClient(
|
return httpx.AsyncClient(
|
||||||
verify=certifi.where(),
|
verify=ssl_context,
|
||||||
timeout=httpx.Timeout(30.0, connect=10.0),
|
timeout=httpx.Timeout(30.0, connect=10.0),
|
||||||
http2=False, # Disable HTTP/2 to avoid compatibility issues
|
http2=False, # Disable HTTP/2 to avoid compatibility issues
|
||||||
limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
|
limits=httpx.Limits(max_keepalive_connections=5, max_connections=10)
|
||||||
|
|||||||
@ -242,8 +242,8 @@ TEMPLATES: Dict[str, Dict[str, Any]] = {
|
|||||||
},
|
},
|
||||||
|
|
||||||
# ── hina_invitation ────────────────────────────────────────────────────────
|
# ── hina_invitation ────────────────────────────────────────────────────────
|
||||||
# Special event template with static body text and dynamic button URL
|
# Special event template with both body and button parameters
|
||||||
# No body parameters - body text is defined in Meta template
|
# Body {{1}} = contact_name (guest's name in greeting)
|
||||||
# Button {{1}} = event_id (dynamic URL parameter)
|
# Button {{1}} = event_id (dynamic URL parameter)
|
||||||
"hina_invitation": {
|
"hina_invitation": {
|
||||||
"meta_name": "hina_invitation",
|
"meta_name": "hina_invitation",
|
||||||
@ -251,12 +251,13 @@ TEMPLATES: Dict[str, Dict[str, Any]] = {
|
|||||||
"friendly_name": "הזמנה לחינה",
|
"friendly_name": "הזמנה לחינה",
|
||||||
"description": "הזמנה לאירוע חינה עם קישור דינמי",
|
"description": "הזמנה לאירוע חינה עם קישור דינמי",
|
||||||
"header_params": [],
|
"header_params": [],
|
||||||
"body_params": [],
|
"body_params": ["contact_name"],
|
||||||
"button_type": "URL",
|
"button_type": "URL",
|
||||||
"button_text": "הצבע על הזמנה",
|
"button_text": "הצבע על הזמנה",
|
||||||
"button_url": "https://invy.dvirlabs.com/guest/{{1}}",
|
"button_url": "https://invy.dvirlabs.com/guest/{{1}}",
|
||||||
"button_param_key": "event_id",
|
"button_param_key": "event_id",
|
||||||
"fallbacks": {
|
"fallbacks": {
|
||||||
|
"contact_name": "חבר",
|
||||||
"event_id": "event-id",
|
"event_id": "event-id",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user