From c1e3e61671f6751db79c563ae55029a3c02c5879 Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Tue, 5 May 2026 17:30:31 +0700 Subject: [PATCH] fix(voice): handle 422 permission-blocked response in WhatsApp call composable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The BE now returns 422 (instead of 200) when the contact hasn't opted in yet — see companion fix in WhatsappCallsController#render_permission_request. Detect that shape in the catch block and surface it as a normal response so the existing banner branch in ConversationHeader.vue keeps working without falling into the error toast path. --- .../dashboard/composables/useWhatsappCallSession.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/javascript/dashboard/composables/useWhatsappCallSession.js b/app/javascript/dashboard/composables/useWhatsappCallSession.js index ead1bb77c..455451703 100644 --- a/app/javascript/dashboard/composables/useWhatsappCallSession.js +++ b/app/javascript/dashboard/composables/useWhatsappCallSession.js @@ -297,6 +297,16 @@ export function useWhatsappCallSession() { return response; } catch (e) { cleanup(); + // BE returns 422 when the contact hasn't opted in (permission template + // sent or already pending). Surface it to the caller as a normal + // response shape so it can render the banner instead of an error toast. + const data = e?.response?.data; + if ( + data?.status === 'permission_requested' || + data?.status === 'permission_pending' + ) { + return { status: data.status }; + } throw e; } finally { isInitiating.value = false;