feat: Add rescheduledBy & canceledBy fields in the DB (#15337)

* feat: Add rescheduledBy & canceledBy fields in the DB

* fix: type check

* fix: type check

* fix: use session user email for reschedule

* fix: unit test

* feat: db field email validation

* feat: rescheduledBy and cancelledBy in webhooks

* revert unrelated changes.

* make session user secondary, default to Anonymous

* if condition not required

* Make cancelledBy optional

Co-authored-by: Syed Ali Shahbaz <[email protected]>

* update cancel booking type

* fix: update cancelledBy in db when requesting reschedule

* remove default value for fields

* fix: type check

* feat: manage fields via api v1

* fix: add fields in booking read api v1

* test: expand to cover new fields

* fix: use cancelledBy param on booking page

---------

Co-authored-by: Anik Dhabal Babu <[email protected]>
Co-authored-by: Syed Ali Shahbaz <[email protected]>
Co-authored-by: Peer Richelsen <[email protected]>
This commit is contained in:
authored and GitHub committed 2024-08-25 11:31:46 +02:00
1 parent 34075ee303
commit b6d31129a3
28 files changed
+139 -20

No files matched your search

+13 -4
View File
@@ -2,7 +2,7 @@ import type { TFunction } from "next-i18next";
import short from "short-uuid";
import { v5 as uuidv5 } from "uuid";
import type { CalendarEvent } from "@calcom/types/Calendar";
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
import { WEBAPP_URL } from "./constants";
import getLabelValueMapFromResponses from "./getLabelValueMapFromResponses";
@@ -217,7 +217,7 @@ export const getPlatformCancelLink = (
return "";
};
export const getCancelLink = (calEvent: CalendarEvent): string => {
export const getCancelLink = (calEvent: CalendarEvent, attendee?: Person): string => {
const Uid = getUid(calEvent);
const seatReferenceUid = getSeatReferenceId(calEvent);
if (calEvent.platformClientId) {
@@ -227,6 +227,9 @@ export const getCancelLink = (calEvent: CalendarEvent): string => {
const cancelLink = new URL(`${calEvent.bookerUrl ?? WEBAPP_URL}/booking/${Uid}`);
cancelLink.searchParams.append("cancel", "true");
cancelLink.searchParams.append("allRemainingBookings", String(!!calEvent.recurringEvent));
if (attendee?.email) {
cancelLink.searchParams.append("cancelledBy", attendee.email);
}
if (seatReferenceUid) cancelLink.searchParams.append("seatReferenceUid", seatReferenceUid);
return cancelLink.toString();
};
@@ -249,7 +252,7 @@ export const getPlatformRescheduleLink = (
return "";
};
export const getRescheduleLink = (calEvent: CalendarEvent): string => {
export const getRescheduleLink = (calEvent: CalendarEvent, attendee?: Person): string => {
const Uid = getUid(calEvent);
const seatUid = getSeatReferenceId(calEvent);
@@ -257,7 +260,13 @@ export const getRescheduleLink = (calEvent: CalendarEvent): string => {
return getPlatformRescheduleLink(calEvent, Uid, seatUid);
}
return `${calEvent.bookerUrl ?? WEBAPP_URL}/reschedule/${seatUid ? seatUid : Uid}`;
const rescheduleLink = new URL(`${calEvent.bookerUrl ?? WEBAPP_URL}/reschedule/${seatUid ? seatUid : Uid}`);
if (attendee?.email) {
rescheduleLink.searchParams.append("rescheduledBy", attendee.email);
}
return rescheduleLink.toString();
};
export const getRichDescription = (
+2
View File
@@ -53,6 +53,8 @@ export const buildBooking = (
status: BookingStatus.ACCEPTED,
paid: false,
destinationCalendarId: null,
cancelledBy: null,
rescheduledBy: null,
cancellationReason: null,
rejectionReason: null,
dynamicEventSlugRef: null,