From 9079ed73ac8ad56a2a64b18edb0f65af98ee9196 Mon Sep 17 00:00:00 2001
From: m5r <mokht@rmi.al>
Date: Mon, 30 Aug 2021 04:33:35 +0800
Subject: [PATCH] differentiate Twilio TwiML app name between environments

---
 app/onboarding/api/queue/set-twilio-webhooks.ts | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/app/onboarding/api/queue/set-twilio-webhooks.ts b/app/onboarding/api/queue/set-twilio-webhooks.ts
index 0e631e3..c3d41a2 100644
--- a/app/onboarding/api/queue/set-twilio-webhooks.ts
+++ b/app/onboarding/api/queue/set-twilio-webhooks.ts
@@ -30,7 +30,7 @@ const setTwilioWebhooks = Queue<Payload>("api/queue/set-twilio-webhooks", async
 				.applications.get(organization.twimlAppSid)
 				.fetch()
 		: await twilio(organization.twilioAccountSid, organization.twilioAuthToken).applications.create({
-				friendlyName: "Shellphone",
+				friendlyName: getTwiMLName(),
 				smsUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-message`,
 				smsMethod: "POST",
 				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;