chore: platform api usage based billing using queue (#15085)

* chore: platform api usage based billing using queue

* fixup! chore: platform api usage based billing using queue

* fixup! fixup! chore: platform api usage based billing using queue

* fixup! Merge branch 'chore-platformapi-billing-queue' of github.com:calcom/cal.com into chore-platformapi-billing-queue

* fixup! fixup! Merge branch 'chore-platformapi-billing-queue' of github.com:calcom/cal.com into chore-platformapi-billing-queue

* fixup! Merge branch 'main' into chore-platformapi-billing-queue

* chore: platform billing by userId

* fix: fix tests requirement team subscirption

* fixup! Merge branch 'main' into chore-platformapi-billing-queue

* fixup! fixup! Merge branch 'main' into chore-platformapi-billing-queue

* fixup! Merge branch 'main' into chore-platformapi-billing-queue

* improve tests logs

* fix: silently close redis and queue

* fixup! Merge branch 'main' into chore-platformapi-billing-queue

* fixup! Merge branch 'main' into chore-platformapi-billing-queue

* fixup! fixup! Merge branch 'main' into chore-platformapi-billing-queue

* fix: upgrade libraries version
This commit is contained in:
Morgan authored and GitHub committed 2024-07-24 17:10:22 +02:00
1 parent 5983c960a6
commit e8b36d5b0b
37 files changed
+347 -91

No files matched your search

@@ -144,6 +144,14 @@ export type CustomRequest = NextApiRequest & {
arePlatformEmailsEnabled?: boolean;
};
export type HandleCancelBookingResponse = {
success: boolean;
message: string;
onlyRemovedAttendee: boolean;
bookingId: number;
bookingUid: string;
};
async function handler(req: CustomRequest) {
const { id, uid, allRemainingBookings, cancellationReason, seatReferenceUid } =
schemaBookingCancelParams.parse(req.body);
@@ -312,7 +320,14 @@ async function handler(req: CustomRequest) {
// If it's just an attendee of a booking then just remove them from that booking
const result = await cancelAttendeeSeat(req, dataForWebhooks);
if (result) return { success: true };
if (result)
return {
success: true,
onlyRemovedAttendee: true,
bookingId: bookingToDelete.id,
bookingUid: bookingToDelete.uid,
message: "Attendee successfully removed.",
} satisfies HandleCancelBookingResponse;
const promises = webhooks.map((webhook) =>
sendPayload(webhook.secret, eventTrigger, new Date().toISOString(), webhook, {
@@ -492,7 +507,13 @@ async function handler(req: CustomRequest) {
console.error("Error deleting event", error);
}
req.statusCode = 200;
return { message: "Booking successfully cancelled." };
return {
success: true,
message: "Booking successfully cancelled.",
onlyRemovedAttendee: false,
bookingId: bookingToDelete.id,
bookingUid: bookingToDelete.uid,
} satisfies HandleCancelBookingResponse;
}
export default handler;
@@ -86,6 +86,15 @@ const handleInstantMeetingWebhookTrigger = async (args: {
}
};
export type HandleInstantMeetingResponse = {
message: string;
meetingTokenId: number;
bookingId: number;
bookingUid: string;
expires: Date;
userId: number | null;
};
async function handler(req: NextApiRequest) {
let eventType = await getEventTypesFromDB(req.body.eventTypeId);
eventType = {
@@ -247,8 +256,10 @@ async function handler(req: NextApiRequest) {
message: "Success",
meetingTokenId: instantMeetingToken.id,
bookingId: newBooking.id,
bookingUid: newBooking.uid,
expires: instantMeetingToken.expires,
};
userId: newBooking.userId,
} satisfies HandleInstantMeetingResponse;
}
export default handler;