receive messages
This commit is contained in:
parent
f1702180b7
commit
a77f02189e
@ -15,7 +15,7 @@ export const action: ActionFunction = async ({ request }) => {
|
|||||||
return badRequest("Invalid header X-Twilio-Signature");
|
return badRequest("Invalid header X-Twilio-Signature");
|
||||||
}
|
}
|
||||||
|
|
||||||
const body: Body = await request.json();
|
const body: Body = Object.fromEntries(await request.formData()) as any;
|
||||||
try {
|
try {
|
||||||
const phoneNumbers = await db.phoneNumber.findMany({
|
const phoneNumbers = await db.phoneNumber.findMany({
|
||||||
where: { number: body.To },
|
where: { number: body.To },
|
||||||
@ -53,10 +53,13 @@ export const action: ActionFunction = async ({ request }) => {
|
|||||||
if (phoneNumbersWithActiveSub.length === 0) {
|
if (phoneNumbersWithActiveSub.length === 0) {
|
||||||
// accept the webhook but don't store incoming message
|
// accept the webhook but don't store incoming message
|
||||||
// because the organization is on the free plan
|
// because the organization is on the free plan
|
||||||
return html("<Response></Response>");
|
console.log("no active subscription"); // TODO: uncomment the line below -- beware: refresh phone numbers refetch those missed messages lol
|
||||||
|
// return html("<Response></Response>");
|
||||||
}
|
}
|
||||||
|
|
||||||
const phoneNumber = phoneNumbersWithActiveSub.find((phoneNumber) => {
|
const phoneNumber = phoneNumbers.find((phoneNumber) => {
|
||||||
|
// TODO: uncomment the line below
|
||||||
|
// const phoneNumber = phoneNumbersWithActiveSub.find((phoneNumber) => {
|
||||||
// if multiple organizations have the same number
|
// if multiple organizations have the same number
|
||||||
// find the organization currently using that phone number
|
// find the organization currently using that phone number
|
||||||
// maybe we shouldn't let that happen by restricting a phone number to one org?
|
// maybe we shouldn't let that happen by restricting a phone number to one org?
|
||||||
|
Loading…
Reference in New Issue
Block a user