Skip to content

Scheduling infrastructure for absolutely everyone.

feat: return participants (#17950)

Udit Takkar9e3d369ac340
diff --git a/packages/features/tasker/tasks/triggerNoShow/common.ts b/packages/features/tasker/tasks/triggerNoShow/common.ts
index 8fab17c7d33..a7aebd06481 100644
--- a/packages/features/tasker/tasks/triggerNoShow/common.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/common.ts
@@ -58,6 +58,7 @@ export function sendWebhookPayload(
triggerEvent: WebhookTriggerEvents,
booking: Booking,
maxStartTime: number,
+ participants: ParticipantsWithEmail,
originalRescheduledBooking?: OriginalRescheduledBooking,
hostEmail?: string
): Promise<any> {
@@ -75,6 +76,7 @@ export function sendWebhookPayload(
startTime: booking.startTime,
attendees: booking.attendees,
endTime: booking.endTime,
+ participants,
...(!!hostEmail ? { hostEmail } : {}),
...(originalRescheduledBooking ? { rescheduledBy: originalRescheduledBooking.rescheduledBy } : {}),
eventType: {
@@ -113,6 +115,29 @@ export function checkIfUserJoinedTheCall(userId: number, allParticipants: Partic
);
}
+const getUserById = async (userId: number) => {
+ return prisma.user.findUnique({
+ where: { id: userId },
+ });
+};
+
+type ParticipantsWithEmail = (Participants[number] & { email?: string })[];
+
+export async function getParticipantsWithEmail(
+ allParticipants: Participants
+): Promise<ParticipantsWithEmail> {
+ const participantsWithEmail = await Promise.all(
+ allParticipants.map(async (participant) => {
+ if (!participant.user_id) return participant;
+
+ const user = await getUserById(parseInt(participant.user_id));
+ return { ...participant, email: user?.email };
+ })
+ );
+
+ return participantsWithEmail;
+}
+
export const log = logger.getSubLogger({ prefix: ["triggerNoShowTask"] });
export const prepareNoShowTrigger = async (
@@ -125,6 +150,7 @@ export const prepareNoShowTrigger = async (
numberOfHostsThatJoined: number;
didGuestJoinTheCall: boolean;
originalRescheduledBooking?: OriginalRescheduledBooking;
+ participants: ParticipantsWithEmail;
} | void> => {
const { bookingId, webhook } = ZSendNoShowWebhookPayloadSchema.parse(JSON.parse(payload));
@@ -192,6 +218,8 @@ export const prepareNoShowTrigger = async (
(meeting) => meeting.max_participants < numberOfHostsThatJoined
);
+ const participantsWithEmail = await getParticipantsWithEmail(allParticipants);
+
return {
hostsThatDidntJoinTheCall,
hostsThatJoinedTheCall,
@@ -200,5 +228,6 @@ export const prepareNoShowTrigger = async (
webhook,
didGuestJoinTheCall,
originalRescheduledBooking,
+ participants: participantsWithEmail,
};
};
diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts
index ff8aa3a2ccd..d7c27f34ce8 100644
--- a/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/triggerGuestNoShow.ts
@@ -30,8 +30,14 @@ export async function triggerGuestNoShow(payload: string): Promise<void> {
const result = await prepareNoShowTrigger(payload);
if (!result) return;
- const { webhook, booking, hostsThatJoinedTheCall, didGuestJoinTheCall, originalRescheduledBooking } =
- result;
+ const {
+ webhook,
+ booking,
+ hostsThatJoinedTheCall,
+ didGuestJoinTheCall,
+ originalRescheduledBooking,
+ participants,
+ } = result;
const maxStartTime = calculateMaxStartTime(booking.startTime, webhook.time, webhook.timeUnit);
@@ -41,6 +47,7 @@ export async function triggerGuestNoShow(payload: string): Promise<void> {
WebhookTriggerEvents.AFTER_GUESTS_CAL_VIDEO_NO_SHOW,
booking,
maxStartTime,
+ participants,
originalRescheduledBooking
);
diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
index 9e17c17c145..3e35c2e63c1 100644
--- a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.test.ts
@@ -159,6 +159,7 @@ describe("Trigger Host No Show:", () => {
attendees: [],
bookingId: 222,
bookingUid: uidOfBooking,
+ participants: [],
hostEmail: "[email protected]",
startTime: `${plus1DateString}T05:00:00.000Z`,
endTime: `${plus1DateString}T05:15:00.000Z`,
@@ -264,6 +265,16 @@ describe("Trigger Host No Show:", () => {
})
);
+ const MOCKED_PARTICIPANTS = [
+ {
+ user_id: null,
+ participant_id: "MOCK_PARTICIPANT_ID",
+ user_name: "MOCK_USER_NAME",
+ join_time: 0,
+ duration: 15,
+ },
+ ];
+
const MOCKED_MEETING_SESSIONS = {
total_count: 1,
data: [
@@ -274,15 +285,7 @@ describe("Trigger Host No Show:", () => {
duration: 15,
max_participants: 1,
// User with id 101 is not in the participants list
- participants: [
- {
- user_id: null,
- participant_id: "MOCK_PARTICIPANT_ID",
- user_name: "MOCK_USER_NAME",
- join_time: 0,
- duration: 15,
- },
- ],
+ participants: MOCKED_PARTICIPANTS,
},
],
};
@@ -320,6 +323,7 @@ describe("Trigger Host No Show:", () => {
attendees: [],
bookingId: 222,
bookingUid: uidOfBooking,
+ participants: MOCKED_PARTICIPANTS,
hostEmail: "[email protected]",
startTime: `${plus1DateString}T05:00:00.000Z`,
endTime: `${plus1DateString}T05:15:00.000Z`,
@@ -464,6 +468,16 @@ describe("Trigger Host No Show:", () => {
})
);
+ const MOCKED_PARTICIPANTS = [
+ {
+ user_id: null,
+ participant_id: "MOCK_PARTICIPANT_ID",
+ user_name: "MOCK_USER_NAME",
+ join_time: 0,
+ duration: 15,
+ },
+ ];
+
const MOCKED_MEETING_SESSIONS = {
total_count: 1,
data: [
@@ -474,15 +488,7 @@ describe("Trigger Host No Show:", () => {
duration: 15,
max_participants: 1,
// User with id 101 is not in the participants list
- participants: [
- {
- user_id: null,
- participant_id: "MOCK_PARTICIPANT_ID",
- user_name: "MOCK_USER_NAME",
- join_time: 0,
- duration: 15,
- },
- ],
+ participants: MOCKED_PARTICIPANTS,
},
],
};
@@ -520,6 +526,7 @@ describe("Trigger Host No Show:", () => {
attendees: [],
bookingId: 224,
bookingUid: newUidOfBooking,
+ participants: MOCKED_PARTICIPANTS,
hostEmail: "[email protected]",
startTime: `${plus1DateString}T05:15:00.000Z`,
endTime: `${plus1DateString}T05:30:00.000Z`,
diff --git a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.ts b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.ts
index 156cab9027b..c7ec3040b69 100644
--- a/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.ts
+++ b/packages/features/tasker/tasks/triggerNoShow/triggerHostNoShow.ts
@@ -37,7 +37,7 @@ export async function triggerHostNoShow(payload: string): Promise<void> {
const result = await prepareNoShowTrigger(payload);
if (!result) return;
- const { booking, webhook, hostsThatDidntJoinTheCall, originalRescheduledBooking } = result;
+ const { booking, webhook, hostsThatDidntJoinTheCall, originalRescheduledBooking, participants } = result;
const maxStartTime = calculateMaxStartTime(booking.startTime, webhook.time, webhook.timeUnit);
@@ -47,6 +47,7 @@ export async function triggerHostNoShow(payload: string): Promise<void> {
WebhookTriggerEvents.AFTER_HOSTS_CAL_VIDEO_NO_SHOW,
booking,
maxStartTime,
+ participants,
originalRescheduledBooking,
host.email
);