From d5ff7dca0612fba576a95f608312f5294c3388a6 Mon Sep 17 00:00:00 2001 From: Erik Harding Date: Thu, 8 Aug 2024 11:40:29 +0200 Subject: [PATCH] Add status id to msisdn change --- go-app-ussd_popi_rapidpro.js | 6 ++++-- src/ussd_popi_rapidpro.js | 6 ++++-- test/ussd_popi_rapidpro.test.js | 27 +++++++++------------------ 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/go-app-ussd_popi_rapidpro.js b/go-app-ussd_popi_rapidpro.js index b4c9f26e..ee0c75e1 100644 --- a/go-app-ussd_popi_rapidpro.js +++ b/go-app-ussd_popi_rapidpro.js @@ -1372,11 +1372,12 @@ go.app = function() { "filename": self.im.config.popi_filename, "id": self.im.config.popi_media_uuid }; - + return self.hub .send_whatsapp_template_message(msisdn, template_name, media) .then(function(data) { self.im.user.set_answer("preferred_channel", data.preferred_channel); + self.im.user.set_answer("status_id", data.status_id); if (data.preferred_channel == "SMS") { return self.rapidpro.get_global_flag("sms_registrations_enabled") .then(function(sms_registration_enabled) { @@ -1428,7 +1429,8 @@ go.app = function() { contact_uuid: self.im.user.answers.contact.uuid, source: "POPI USSD", old_channel: channel, - new_wa_id: new_wa_id + new_wa_id: new_wa_id, + status_id: self.im.user.answers.status_id, } ) .then(function() { diff --git a/src/ussd_popi_rapidpro.js b/src/ussd_popi_rapidpro.js index 49040ab7..aa5ed2c9 100644 --- a/src/ussd_popi_rapidpro.js +++ b/src/ussd_popi_rapidpro.js @@ -1200,11 +1200,12 @@ go.app = function() { "filename": self.im.config.popi_filename, "id": self.im.config.popi_media_uuid }; - + return self.hub .send_whatsapp_template_message(msisdn, template_name, media) .then(function(data) { self.im.user.set_answer("preferred_channel", data.preferred_channel); + self.im.user.set_answer("status_id", data.status_id); if (data.preferred_channel == "SMS") { return self.rapidpro.get_global_flag("sms_registrations_enabled") .then(function(sms_registration_enabled) { @@ -1256,7 +1257,8 @@ go.app = function() { contact_uuid: self.im.user.answers.contact.uuid, source: "POPI USSD", old_channel: channel, - new_wa_id: new_wa_id + new_wa_id: new_wa_id, + status_id: self.im.user.answers.status_id, } ) .then(function() { diff --git a/test/ussd_popi_rapidpro.test.js b/test/ussd_popi_rapidpro.test.js index ac349e71..f2a52e6c 100644 --- a/test/ussd_popi_rapidpro.test.js +++ b/test/ussd_popi_rapidpro.test.js @@ -751,7 +751,7 @@ describe("ussd_popi_rapidpro app", function() { .check.user.state("state_baby_born_complete") .check.interaction({ reply: [ - "Your baby's date of birth has been updated " + + "Your baby's date of birth has been updated " + "to 2022-04-04 and you will start receiving " + "messages based on this schedule.", "1. Back", @@ -1359,7 +1359,8 @@ describe("ussd_popi_rapidpro app", function() { "filename": "privacy_policy.pdf", "id": "media-uuid" }, - "SMS" + "SMS", + "status-id-uuid" ) ); api.http.fixtures.add( @@ -1374,10 +1375,11 @@ describe("ussd_popi_rapidpro app", function() { source: "POPI USSD", old_channel: "WhatsApp", new_wa_id: "whatsapp:27820001001", + status_id: "status-id-uuid", } ) ); - + }) .input("1") .check.user.state("state_msisdn_change_success") @@ -1407,20 +1409,7 @@ describe("ussd_popi_rapidpro app", function() { ); api.http.fixtures.add( fixtures_rapidpro.get_global_flag("sms_registrations_enabled", "FALSE") - ); - api.http.fixtures.add( - fixtures_rapidpro.start_flow( - "msisdn-change-flow", null, "whatsapp:27820001001", { - new_msisdn: "+27820001001", - old_msisdn: "+27123456789", - contact_uuid: "contact-uuid", - source: "POPI USSD", - old_channel: "WhatsApp", - new_wa_id: "whatsapp:27820001001", - } - ) ); - }) .input("1") .check.user.state("state_sms_registration_not_available") @@ -1445,7 +1434,8 @@ describe("ussd_popi_rapidpro app", function() { "filename": "privacy_policy.pdf", "id": "media-uuid" }, - "WhatsApp" + "WhatsApp", + "status-id-uuid" ) ); api.http.fixtures.add( @@ -1460,10 +1450,11 @@ describe("ussd_popi_rapidpro app", function() { source: "POPI USSD", old_channel: "WhatsApp", new_wa_id: "whatsapp:27820001001", + status_id: "status-id-uuid", } ) ); - + }) .input("1") .check.user.state("state_msisdn_change_success")