diff --git a/backend/main.py b/backend/main.py index e01fe1f..064aafc 100644 --- a/backend/main.py +++ b/backend/main.py @@ -81,9 +81,9 @@ def _fix_template_parameters(): if template: # Expected correct parameters for hina_invitation - # hina_invitation has NO body parameters (body is static in Meta) - # Only has button parameter: event_id - expected_params = [] + # Body {{1}} = contact_name (guest's name) + # Button {{1}} = event_id (sent as separate button parameter) + expected_params = ["contact_name"] try: current_params = json.loads(template.body_params) @@ -2001,12 +2001,15 @@ async def test_whatsapp_send( 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 = { + "contact_name": "Test", "event_id": "test-event-123" } - # Use hina_invitation template (static body, dynamic button URL) + # Use hina_invitation template template_key = "hina_invitation" result = await service.send_by_template_key( diff --git a/backend/whatsapp.py b/backend/whatsapp.py index 7ec439b..38a8f99 100644 --- a/backend/whatsapp.py +++ b/backend/whatsapp.py @@ -17,11 +17,16 @@ logger = logging.getLogger(__name__) async def create_http_client() -> httpx.AsyncClient: """ 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( - verify=certifi.where(), + verify=ssl_context, timeout=httpx.Timeout(30.0, connect=10.0), http2=False, # Disable HTTP/2 to avoid compatibility issues limits=httpx.Limits(max_keepalive_connections=5, max_connections=10) diff --git a/backend/whatsapp_templates.py b/backend/whatsapp_templates.py index 8f757c4..5333560 100644 --- a/backend/whatsapp_templates.py +++ b/backend/whatsapp_templates.py @@ -242,8 +242,8 @@ TEMPLATES: Dict[str, Dict[str, Any]] = { }, # ── hina_invitation ──────────────────────────────────────────────────────── - # Special event template with static body text and dynamic button URL - # No body parameters - body text is defined in Meta template + # Special event template with both body and button parameters + # Body {{1}} = contact_name (guest's name in greeting) # Button {{1}} = event_id (dynamic URL parameter) "hina_invitation": { "meta_name": "hina_invitation", @@ -251,12 +251,13 @@ TEMPLATES: Dict[str, Dict[str, Any]] = { "friendly_name": "הזמנה לחינה", "description": "הזמנה לאירוע חינה עם קישור דינמי", "header_params": [], - "body_params": [], + "body_params": ["contact_name"], "button_type": "URL", "button_text": "הצבע על הזמנה", "button_url": "https://invy.dvirlabs.com/guest/{{1}}", "button_param_key": "event_id", "fallbacks": { + "contact_name": "חבר", "event_id": "event-id", }, },