From c76587f0921dd5a7fcf69003f65e3267df90a89c Mon Sep 17 00:00:00 2001 From: engelhartrueben Date: Mon, 9 Dec 2024 17:44:35 -0500 Subject: [PATCH] adjust when contact and handler context are checked --- .../message-handlers/ngpvan-optout/index.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/extensions/message-handlers/ngpvan-optout/index.js b/src/extensions/message-handlers/ngpvan-optout/index.js index 3fe654e76..4d092cd1f 100644 --- a/src/extensions/message-handlers/ngpvan-optout/index.js +++ b/src/extensions/message-handlers/ngpvan-optout/index.js @@ -28,7 +28,6 @@ export const available = organization => /* Sends a request to VAN to place an opt out tag to an individual. */ export const postMessageSave = async ({ - _, // message contact, handlerContext, organization @@ -38,6 +37,11 @@ export const postMessageSave = async ({ let customField; let vanId; + if ( + !contact || + !handlerContext.autoOptOutReason + ) return {}; + // Checking for vanID in contact // While Van.postCanvassResponse will check the customFields, // we don't want to call that function every time if a vanid @@ -51,11 +55,6 @@ export const postMessageSave = async ({ return {}; } - if ( - !contact || - !handlerContext.autoOptOutReason - ) return {}; - // Testing shows that "-" , "(", and ")" break this request const cell = contact.cell.replace(/\D/g,'')