clean setTwilioWebhooks and twilio webhook verification

This commit is contained in:
m5r
2021-08-30 19:24:05 +08:00
parent e77e7d17e0
commit 6a2e76857b
5 changed files with 39 additions and 26 deletions

View File

@ -1,4 +1,4 @@
import { NotFoundError } from "blitz";
import { getConfig, NotFoundError } from "blitz";
import twilio from "twilio";
import type { Organization } from "db";
@ -19,3 +19,20 @@ export default function getTwilioClient(organization: MinimalOrganization | null
accountSid: organization.twilioAccountSid,
});
}
const { serverRuntimeConfig } = getConfig();
export const smsUrl = `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-message`;
export const voiceUrl = `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/call`;
export 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";
}
}