fetch dismissed messages and phone calls that might have happened while on free plan
This commit is contained in:
parent
a4859137fe
commit
950a7e1bd0
@ -7,6 +7,8 @@ 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 "app/messages/api/queue/fetch-messages";
|
||||
import fetchCallsQueue from "app/phone-calls/api/queue/fetch-calls";
|
||||
|
||||
const logger = appLogger.child({ queue: "subscription-created" });
|
||||
|
||||
@ -49,6 +51,30 @@ export const subscriptionCreatedQueue = Queue<Payload>("api/queue/subscription-c
|
||||
},
|
||||
});
|
||||
|
||||
// fetch dismissed messages and phone calls that might have happened while on free plan
|
||||
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",
|
||||
|
Loading…
Reference in New Issue
Block a user