fetch phone number data even if user is not on a paid plan
This commit is contained in:
parent
5df0634060
commit
7a4c583ea5
@ -7,8 +7,6 @@ import appLogger from "integrations/logger";
|
||||
import { sendEmail } from "integrations/aws-ses";
|
||||
import type { Metadata } from "integrations/paddle";
|
||||
import { translateSubscriptionStatus } from "integrations/paddle";
|
||||
import fetchMessagesQueue from "../../../messages/api/queue/fetch-messages";
|
||||
import fetchCallsQueue from "../../../phone-calls/api/queue/fetch-calls";
|
||||
|
||||
const logger = appLogger.child({ queue: "subscription-created" });
|
||||
|
||||
@ -51,29 +49,6 @@ export const subscriptionCreatedQueue = Queue<Payload>("api/queue/subscription-c
|
||||
},
|
||||
});
|
||||
|
||||
const phoneNumber = organization.phoneNumbers[0];
|
||||
if (phoneNumber) {
|
||||
const phoneNumberId = phoneNumber.id;
|
||||
await Promise.all([
|
||||
db.processingPhoneNumber.create({
|
||||
data: {
|
||||
organizationId,
|
||||
phoneNumberId,
|
||||
hasFetchedMessages: false,
|
||||
hasFetchedCalls: false,
|
||||
},
|
||||
}),
|
||||
fetchMessagesQueue.enqueue(
|
||||
{ organizationId, phoneNumberId },
|
||||
{ id: `fetch-messages-${organizationId}-${phoneNumberId}` },
|
||||
),
|
||||
fetchCallsQueue.enqueue(
|
||||
{ organizationId, phoneNumberId },
|
||||
{ id: `fetch-messages-${organizationId}-${phoneNumberId}` },
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (isReturningSubscriber) {
|
||||
sendEmail({
|
||||
subject: "Welcome back to Shellphone",
|
||||
|
@ -6,8 +6,8 @@ import RestException from "twilio/lib/base/RestException";
|
||||
import db from "db";
|
||||
import getCurrentUser from "app/users/queries/get-current-user";
|
||||
import setTwilioWebhooks from "../api/queue/set-twilio-webhooks";
|
||||
import fetchMessagesQueue from "../../messages/api/queue/fetch-messages";
|
||||
import fetchCallsQueue from "../../phone-calls/api/queue/fetch-calls";
|
||||
import fetchMessagesQueue from "app/messages/api/queue/fetch-messages";
|
||||
import fetchCallsQueue from "app/phone-calls/api/queue/fetch-calls";
|
||||
|
||||
const Body = z.object({
|
||||
phoneNumberSid: z.string(),
|
||||
@ -81,16 +81,11 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({
|
||||
}
|
||||
|
||||
const phoneNumberId = phoneNumberSid;
|
||||
let promises: Promise<any>[] = [
|
||||
await Promise.all([
|
||||
setTwilioWebhooks.enqueue(
|
||||
{ organizationId, phoneNumberId },
|
||||
{ id: `set-twilio-webhooks-${organizationId}-${phoneNumberId}` },
|
||||
),
|
||||
];
|
||||
|
||||
const hasActiveSubscription = organization.subscriptions.length > 0;
|
||||
if (hasActiveSubscription) {
|
||||
promises.push(
|
||||
db.processingPhoneNumber.create({
|
||||
data: {
|
||||
organizationId,
|
||||
@ -107,8 +102,5 @@ export default resolver.pipe(resolver.zod(Body), resolver.authorize(), async ({
|
||||
{ organizationId, phoneNumberId },
|
||||
{ id: `fetch-messages-${organizationId}-${phoneNumberId}` },
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
await Promise.all(promises);
|
||||
]);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user