smol fixes to subscription webhooks
This commit is contained in:
parent
4096cfaa6c
commit
4ce3c2503a
@ -1,4 +1,3 @@
|
||||
import { NotFoundError } from "blitz";
|
||||
import { Queue } from "quirrel/blitz";
|
||||
import type { PaddleSdkSubscriptionCancelledEvent } from "@devoxa/paddle-sdk";
|
||||
|
||||
@ -17,7 +16,8 @@ export const subscriptionCancelledQueue = Queue<Payload>("api/queue/subscription
|
||||
const paddleSubscriptionId = event.subscriptionId;
|
||||
const subscription = await db.subscription.findFirst({ where: { paddleSubscriptionId } });
|
||||
if (!subscription) {
|
||||
throw new NotFoundError();
|
||||
// user deleted their account, no need to update their subscription
|
||||
return;
|
||||
}
|
||||
|
||||
const lastEventTime = event.eventTime;
|
||||
|
@ -9,7 +9,6 @@ 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";
|
||||
import setTwilioWebhooks from "./set-twilio-webhooks";
|
||||
|
||||
const logger = appLogger.child({ queue: "subscription-created" });
|
||||
|
||||
@ -52,7 +51,9 @@ export const subscriptionCreatedQueue = Queue<Payload>("api/queue/subscription-c
|
||||
},
|
||||
});
|
||||
|
||||
const phoneNumberId = organization.phoneNumbers[0]!.id;
|
||||
const phoneNumber = organization.phoneNumbers[0];
|
||||
if (phoneNumber) {
|
||||
const phoneNumberId = phoneNumber.id;
|
||||
await Promise.all([
|
||||
db.processingPhoneNumber.create({
|
||||
data: {
|
||||
@ -71,6 +72,7 @@ export const subscriptionCreatedQueue = Queue<Payload>("api/queue/subscription-c
|
||||
{ id: `fetch-messages-${organizationId}-${phoneNumberId}` },
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
if (isReturningSubscriber) {
|
||||
sendEmail({
|
||||
|
Loading…
Reference in New Issue
Block a user