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

@@ -5,8 +5,8 @@ export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person })
// Only the original attendee can make changes to the event
// Guests cannot
const t = props.attendee.language.translate;
const cancelLink = getCancelLink(props.calEvent);
const rescheduleLink = getRescheduleLink(props.calEvent);
const cancelLink = getCancelLink(props.calEvent, props.attendee);
const rescheduleLink = getRescheduleLink(props.calEvent, props.attendee);
const bookingLink = getBookingUrl(props.calEvent);
const isOriginalAttendee = props.attendee.email === props.calEvent.attendees[0]?.email;
@@ -16,9 +16,10 @@ export function ManageLink(props: { calEvent: CalendarEvent; attendee: Person })
const hasBookingLink = Boolean(bookingLink);
const isRecurringEvent = props.calEvent.recurringEvent;
const shouldDisplayRescheduleLink = Boolean(hasRescheduleLink && !isRecurringEvent);
const isTeamMember = props.calEvent.team?.members.some((member) => props.attendee.email === member.email);
if (
(isOriginalAttendee || isOrganizer) &&
(isOriginalAttendee || isOrganizer || isTeamMember) &&
(hasCancelLink || (!isRecurringEvent && hasRescheduleLink) || hasBookingLink)
) {
return (
@@ -1,3 +1,4 @@
import { SchedulingType } from "@prisma/client";
import type { CalendarEvent, Person } from "@calcom/types/Calendar";
import { BaseScheduledEmail } from "./BaseScheduledEmail";
@@ -32,6 +33,9 @@ export const OrganizerScheduledEmail = (
const locale = props.teamMember?.language.locale || props.calEvent.organizer.language.locale;
const timeFormat = props.teamMember?.timeFormat || props.calEvent.organizer?.timeFormat;
const isTeamEvent = props.calEvent.schedulingType === SchedulingType.ROUND_ROBIN || props.calEvent.schedulingType === SchedulingType.COLLECTIVE;
const attendee = isTeamEvent && props.teamMember ? props.teamMember : props.attendee;
return (
<BaseScheduledEmail
locale={locale}
@@ -50,6 +54,7 @@ export const OrganizerScheduledEmail = (
</>
}
{...props}
attendee={attendee}
/>
);
};