feat: Add new events to webhook BOOKING_CONFIRMED, BOOKING_REJECTED (#8884)
* test: booking rejection * test: check if webhook is called * feat: BOOKING_REJECTED enum ,constant in backend * feat: send booking rejected webhook to subscribers * feat: add Booking rejected migration * calendar event * Revert "calendar event" This reverts commit 28d45dccfdd3788f0124f9be8783161b1156cd09. * feat: BOOKING_REQUESTED enum, constant, migration * feat: Send BOOKING REQUESTED Webhook call * feat: Add booking rejected/requested event in form * feat: data-testid to rejection confirm btn * test: BOOKING_REJECTED, BOOKING_REQUESTED * fix: booking status PENDING, Linting * feat: add new labels to common.json * remove: meeting ended hook from request hook * refactor: abstract handleWebhookTrigger * fix: create a single file for migration * refactor: reduce code repetition and fix test * feat: add team webhooks to subscriberOptions * refactor: subscriberOptions --------- Co-authored-by: Joe Au-Yeung <[email protected]> Co-authored-by: Peer Richelsen <[email protected]> Co-authored-by: Alex van Andel <[email protected]>
This commit is contained in:
11 files changed
+479
-160
No files matched your search
@@ -4,10 +4,12 @@ import appStore from "@calcom/app-store";
|
||||
import { sendDeclinedEmails } from "@calcom/emails";
|
||||
import { getCalEventResponses } from "@calcom/features/bookings/lib/getCalEventResponses";
|
||||
import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation";
|
||||
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
|
||||
import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
|
||||
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
|
||||
import { getTranslation } from "@calcom/lib/server";
|
||||
import { prisma } from "@calcom/prisma";
|
||||
import { BookingStatus, MembershipRole, SchedulingType } from "@calcom/prisma/enums";
|
||||
import { BookingStatus, MembershipRole, SchedulingType, WebhookTriggerEvents } from "@calcom/prisma/enums";
|
||||
import type { CalendarEvent } from "@calcom/types/Calendar";
|
||||
import type { IAbstractPaymentService } from "@calcom/types/PaymentService";
|
||||
|
||||
@@ -304,6 +306,31 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
|
||||
}
|
||||
|
||||
await sendDeclinedEmails(evt);
|
||||
// send BOOKING_REJECTED webhooks
|
||||
const subscriberOptions = {
|
||||
userId: booking.userId,
|
||||
eventTypeId: booking.eventTypeId,
|
||||
triggerEvent: WebhookTriggerEvents.BOOKING_REJECTED,
|
||||
teamId: booking.eventType?.teamId,
|
||||
};
|
||||
const eventTrigger: WebhookTriggerEvents = WebhookTriggerEvents.BOOKING_REJECTED;
|
||||
const eventTypeInfo: EventTypeInfo = {
|
||||
eventTitle: booking.eventType?.title,
|
||||
eventDescription: booking.eventType?.description,
|
||||
requiresConfirmation: booking.eventType?.requiresConfirmation || null,
|
||||
price: booking.eventType?.price,
|
||||
currency: booking.eventType?.currency,
|
||||
length: booking.eventType?.length,
|
||||
};
|
||||
const webhookData = {
|
||||
...evt,
|
||||
...eventTypeInfo,
|
||||
bookingId,
|
||||
eventTypeId: booking.eventType?.id,
|
||||
status: BookingStatus.REJECTED,
|
||||
smsReminderNumber: booking.smsReminderNumber || undefined,
|
||||
};
|
||||
await handleWebhookTrigger({ subscriberOptions, eventTrigger, webhookData });
|
||||
}
|
||||
|
||||
const message = "Booking " + confirmed ? "confirmed" : "rejected";
|
||||
|
||||
Reference in new issue
Block a user