Scheduling infrastructure for absolutely everyone.
fix: mark guest are no show (#17588)
Udit Takkarc7f11c67956a
diff --git a/packages/features/tasker/tasks/triggerNoShow/common.ts b/packages/features/tasker/tasks/triggerNoShow/common.tsindex 0f338cd3ddd..a9d35185175 100644--- a/packages/features/tasker/tasks/triggerNoShow/common.ts+++ b/packages/features/tasker/tasks/triggerNoShow/common.ts@@ -111,6 +111,7 @@ export const prepareNoShowTrigger = async (booking: Booking;webhook: TWebhook;hostsThatDidntJoinTheCall: Host[];+ hostsThatJoinedTheCall: Host[];numberOfHostsThatJoined: number;didGuestJoinTheCall: boolean;} | void> => {@@ -148,9 +149,16 @@ export const prepareNoShowTrigger = async (const hosts = getHosts(booking);const allParticipants = meetingDetails.data.flatMap((meeting) => meeting.participants);- const hostsThatDidntJoinTheCall = hosts.filter(- (host) => !checkIfUserJoinedTheCall(host.id, allParticipants)- );+ const hostsThatJoinedTheCall: Host[] = [];+ const hostsThatDidntJoinTheCall: Host[] = [];++ for (const host of hosts) {+ if (checkIfUserJoinedTheCall(host.id, allParticipants)) {+ hostsThatJoinedTheCall.push(host);+ } else {+ hostsThatDidntJoinTheCall.push(host);+ }+ }const numberOfHostsThatJoined = hosts.length - hostsThatDidntJoinTheCall.length;@@ -158,5 +166,12 @@ export const prepareNoShowTrigger = async ((meeting) => meeting.max_participants < numberOfHostsThatJoined);- return { hostsThatDidntJoinTheCall, booking, numberOfHostsThatJoined, webhook, didGuestJoinTheCall };+ return {+ hostsThatDidntJoinTheCall,+ hostsThatJoinedTheCall,+ booking,+ numberOfHostsThatJoined,+ webhook,+ didGuestJoinTheCall,+ };};diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.tsindex 3c9f82e4d1a..826af8206c1 100644--- a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts+++ b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts@@ -1,12 +1,36 @@+import { prisma } from "@calcom/prisma";import { WebhookTriggerEvents } from "@calcom/prisma/enums";-import { calculateMaxStartTime, sendWebhookPayload, prepareNoShowTrigger } from "./common";+import { calculateMaxStartTime, sendWebhookPayload, prepareNoShowTrigger, log } from "./common";+import type { Host } from "./common";++const markAllGuestNoshowInBooking = async ({+ bookingId,+ hostsThatJoinedTheCall,+}: {+ bookingId: number;+ hostsThatJoinedTheCall: Host[];+}) => {+ try {+ const hostsThatJoinedTheCallEmails = hostsThatJoinedTheCall.map((h) => h.email);++ await prisma.attendee.updateMany({+ where: {+ bookingId,+ email: { notIn: hostsThatJoinedTheCallEmails },+ },+ data: { noShow: true },+ });+ } catch (err) {+ log.error("Error marking guests as no show in booking", err);+ }+};export async function triggerGuestNoShow(payload: string): Promise<void> {const result = await prepareNoShowTrigger(payload);if (!result) return;- const { webhook, booking, didGuestJoinTheCall } = result;+ const { webhook, booking, hostsThatJoinedTheCall, didGuestJoinTheCall } = result;const maxStartTime = calculateMaxStartTime(booking.startTime, webhook.time, webhook.timeUnit);@@ -17,5 +41,7 @@ export async function triggerGuestNoShow(payload: string): Promise<void> {booking,maxStartTime);++ await markAllGuestNoshowInBooking({ bookingId: booking.id, hostsThatJoinedTheCall });}}