rename to shellphone

This commit is contained in:
m5r
2021-08-03 21:03:10 +08:00
parent 002c3ad37f
commit e98697293a
6 changed files with 15 additions and 13 deletions

View File

@ -1,3 +1,4 @@
import { getConfig } from "blitz";
import { Queue } from "quirrel/blitz";
import twilio from "twilio";
@ -7,6 +8,8 @@ type Payload = {
customerId: string;
};
const { serverRuntimeConfig } = getConfig();
const setTwilioWebhooks = Queue<Payload>("api/queue/set-twilio-webhooks", async ({ customerId }) => {
const [customer, phoneNumber] = await Promise.all([
db.customer.findFirst({ where: { id: customerId } }),
@ -19,10 +22,10 @@ const setTwilioWebhooks = Queue<Payload>("api/queue/set-twilio-webhooks", async
const twimlApp = customer.twimlAppSid
? await twilio(customer.accountSid, customer.authToken).applications.get(customer.twimlAppSid).fetch()
: await twilio(customer.accountSid, customer.authToken).applications.create({
friendlyName: "Virtual Phone",
smsUrl: "https://phone.mokhtar.dev/api/webhook/incoming-message",
friendlyName: "Shellphone",
smsUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-message`,
smsMethod: "POST",
voiceUrl: "https://phone.mokhtar.dev/api/webhook/incoming-call",
voiceUrl: `https://${serverRuntimeConfig.app.baseUrl}/api/webhook/incoming-call`,
voiceMethod: "POST",
});
const twimlAppSid = twimlApp.sid;