fix: Broken reschedule link in email created by workflow for team event (#13893)

* add reschedule link if event if type team

* fix type errors

* fix type errors

* change team.name to team.slug

* fix type_errors

* fix type-errors

* fix type-errors

* fetch team from db

* make rescheduleLink dynamic (temp_changes)

* fix type-error

* add org support

* fix type errors

* remove old org code

* use /reschedule/uid instead

* remove not needed changes

* implement feedback

* code clean up

---------

Co-authored-by: CarinaWolli <[email protected]>
Co-authored-by: Carina Wollendorfer <[email protected]>
Co-authored-by: Udit Takkar <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-03-20 19:07:48 +00:00
1 parent 6ea13b7c9a
commit 602fd6879f
10 files changed
+182 -76

No files matched your search

@@ -7,6 +7,7 @@ import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirma
import { handleWebhookTrigger } from "@calcom/features/bookings/lib/handleWebhookTrigger";
import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib";
import { getBookerBaseUrl } from "@calcom/lib/getBookerUrl/server";
import { getTeamIdFromEventType } from "@calcom/lib/getTeamIdFromEventType";
import { getTranslation } from "@calcom/lib/server";
import { getUsersCredentials } from "@calcom/lib/server/getUsersCredentials";
@@ -66,6 +67,11 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
bookingFields: true,
disableGuests: true,
metadata: true,
team: {
select: {
parentId: true,
},
},
workflows: {
include: {
workflow: {
@@ -154,12 +160,25 @@ export const confirmHandler = async ({ ctx, input }: ConfirmOptions) => {
};
});
const organizerOrganizationProfile = await prisma.profile.findFirst({
where: {
userId: user.id,
},
});
const organizerOrganizationId = organizerOrganizationProfile?.organizationId;
const bookerUrl = await getBookerBaseUrl(
booking.eventType?.team?.parentId ?? organizerOrganizationId ?? null
);
const attendeesList = await Promise.all(attendeesListPromises);
const evt: CalendarEvent = {
type: booking?.eventType?.slug as string,
title: booking.title,
description: booking.description,
bookerUrl,
// TODO: Remove the usage of `bookingFields` in computing responses. We can do that by storing `label` with the response. Also, this would allow us to correctly show the label for a field even after the Event Type has been deleted.
...getCalEventResponses({
bookingFields: booking.eventType?.bookingFields ?? null,