differentiate Twilio TwiML app name between environments

This commit is contained in:
m5r 2021-08-30 04:33:35 +08:00
parent 549558142d
commit 9079ed73ac

View File

@ -30,7 +30,7 @@ const setTwilioWebhooks = Queue<Payload>("api/queue/set-twilio-webhooks", async
.applications.get(organization.twimlAppSid) .applications.get(organization.twimlAppSid)
.fetch() .fetch()
: await twilio(organization.twilioAccountSid, organization.twilioAuthToken).applications.create({ : await twilio(organization.twilioAccountSid, organization.twilioAuthToken).applications.create({
friendlyName: "Shellphone", friendlyName: getTwiMLName(),
smsUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-message`, smsUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-message`,
smsMethod: "POST", smsMethod: "POST",
voiceUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-call`, voiceUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-call`,
@ -52,4 +52,15 @@ const setTwilioWebhooks = Queue<Payload>("api/queue/set-twilio-webhooks", async
]); ]);
}); });
function getTwiMLName() {
switch (serverRuntimeConfig.app.baseUrl) {
case "local.shellphone.app":
return "Shellphone LOCAL";
case "dev.shellphone.app":
return "Shellphone DEV";
case "www.shellphone.app":
return "Shellphone";
}
}
export default setTwilioWebhooks; export default setTwilioWebhooks;