Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add status id to msisdn change #641

Merged
merged 1 commit into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions go-app-ussd_popi_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
6 changes: 4 additions & 2 deletions src/ussd_popi_rapidpro.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
27 changes: 9 additions & 18 deletions test/ussd_popi_rapidpro.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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(
Expand All @@ -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")
Expand Down Expand Up @@ -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")
Expand All @@ -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(
Expand All @@ -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")
Expand Down
Loading