fix: metadata for seats in webhooks (#14025)
* add metadata to seats for workflows and webhooks * add test --------- Co-authored-by: CarinaWolli <wollencarina@gmail.com> Co-authored-by: Alex van Andel <me@alexvanandel.com>
This commit is contained in:
co-authored by
CarinaWolli
Alex van Andel
parent
d6d2aae67f
commit
cb30e5f1e0
@@ -864,6 +864,7 @@ export const findBookingQuery = async (bookingId: number) => {
|
||||
description: true,
|
||||
status: true,
|
||||
responses: true,
|
||||
metadata: true,
|
||||
user: {
|
||||
select: {
|
||||
name: true,
|
||||
|
||||
@@ -96,8 +96,10 @@ const handleSeats = async (newSeatedBookingObject: NewSeatedBookingObject) => {
|
||||
|
||||
// If the resultBooking is defined we should trigger workflows else, trigger in handleNewBooking
|
||||
if (resultBooking) {
|
||||
// Obtain event metadata that includes videoCallUrl
|
||||
const metadata = evt.videoCallData?.url ? { videoCallUrl: evt.videoCallData.url } : undefined;
|
||||
const metadata = {
|
||||
...(typeof resultBooking.metadata === "object" && resultBooking.metadata),
|
||||
...reqBodyMetadata,
|
||||
};
|
||||
try {
|
||||
await scheduleWorkflowReminders({
|
||||
workflows: eventType.workflows,
|
||||
@@ -126,7 +128,7 @@ const handleSeats = async (newSeatedBookingObject: NewSeatedBookingObject) => {
|
||||
rescheduleEndTime: originalRescheduledBooking?.endTime
|
||||
? dayjs(originalRescheduledBooking?.endTime).utc().format()
|
||||
: undefined,
|
||||
metadata: { ...metadata, ...reqBodyMetadata },
|
||||
metadata,
|
||||
eventTypeId,
|
||||
status: "ACCEPTED",
|
||||
smsReminderNumber: seatedBooking?.smsReminderNumber || undefined,
|
||||
|
||||
@@ -187,7 +187,9 @@ describe("handleSeats", () => {
|
||||
body: mockBookingData,
|
||||
});
|
||||
|
||||
await handleNewBooking(req);
|
||||
const createdBooking = await handleNewBooking(req);
|
||||
|
||||
expect(createdBooking.metadata).toHaveProperty("videoCallUrl");
|
||||
|
||||
const handleSeatsCall = spy.mock.calls[0][0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user