fix: reset exceeded at when upgrading account
This commit is contained in:
@@ -169,6 +169,11 @@ export async function polarWebhook(
|
|||||||
.parse(event.data.metadata);
|
.parse(event.data.metadata);
|
||||||
|
|
||||||
const product = await getProduct(event.data.productId);
|
const product = await getProduct(event.data.productId);
|
||||||
|
const organization = await db.organization.findUniqueOrThrow({
|
||||||
|
where: {
|
||||||
|
id: metadata.organizationId,
|
||||||
|
},
|
||||||
|
});
|
||||||
const eventsLimit = product.metadata?.eventsLimit;
|
const eventsLimit = product.metadata?.eventsLimit;
|
||||||
const subscriptionPeriodEventsLimit =
|
const subscriptionPeriodEventsLimit =
|
||||||
typeof eventsLimit === 'number' ? eventsLimit : undefined;
|
typeof eventsLimit === 'number' ? eventsLimit : undefined;
|
||||||
@@ -216,6 +221,13 @@ export async function polarWebhook(
|
|||||||
subscriptionCreatedByUserId: metadata.userId,
|
subscriptionCreatedByUserId: metadata.userId,
|
||||||
subscriptionInterval: event.data.recurringInterval,
|
subscriptionInterval: event.data.recurringInterval,
|
||||||
subscriptionPeriodEventsLimit,
|
subscriptionPeriodEventsLimit,
|
||||||
|
subscriptionPeriodEventsCountExceededAt:
|
||||||
|
subscriptionPeriodEventsLimit &&
|
||||||
|
organization.subscriptionPeriodEventsCountExceededAt &&
|
||||||
|
organization.subscriptionPeriodEventsLimit <
|
||||||
|
subscriptionPeriodEventsLimit
|
||||||
|
? null
|
||||||
|
: undefined,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user