Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion apps/web/lib/reschedule/[uid]/getServerSideProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,20 @@ export async function getServerSideProps(context: GetServerSidePropsContext) {
// If the booking is CANCELLED and allowRescheduleForCancelledBooking is false, we redirect the user to the original event link.
// A booking that has been rescheduled to a new booking will also have a status of CANCELLED
const isDisabledRescheduling = booking.eventType?.disableRescheduling;

const userId = session?.user?.id;
const isHost =
userId &&
(eventType?.userId === userId ||
eventType?.owner?.id === userId ||
eventType?.hosts?.some((host) => host.user.id === userId));

// This comes from query param and thus is considered forced
const canBookThroughCancelledBookingRescheduleLink = booking.eventType?.allowReschedulingCancelledBookings;
const isNonRescheduleableBooking =
booking.status === BookingStatus.CANCELLED || booking.status === BookingStatus.REJECTED;

if (isDisabledRescheduling) {
if (isDisabledRescheduling && !isHost) {
return {
redirect: {
destination: `/booking/${uid}`,
Expand Down
8 changes: 4 additions & 4 deletions apps/web/modules/bookings/views/bookings-single-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -376,11 +376,11 @@ export default function Success(props: PageProps) {
const isRerouting = searchParams?.get("cal.rerouting") === "true";
const isRescheduled = bookingInfo?.rescheduled;

const canCancelOrReschedule = !eventType?.disableCancelling || !eventType?.disableRescheduling;
const canCancelAndReschedule = !eventType?.disableCancelling && !eventType?.disableRescheduling;
const canCancelOrReschedule = !eventType?.disableCancelling || !eventType?.disableRescheduling || isHost;
const canCancelAndReschedule = (!eventType?.disableCancelling && !eventType?.disableRescheduling) || isHost;

const canCancel = !eventType?.disableCancelling;
const canReschedule = !eventType?.disableRescheduling;
const canCancel = !eventType?.disableCancelling || isHost;
const canReschedule = !eventType?.disableRescheduling || isHost;

const successPageHeadline = (() => {
if (needsConfirmationAndReschedulable) {
Expand Down
5 changes: 4 additions & 1 deletion apps/web/server/lib/[user]/[type]/getServerSideProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,10 @@ async function processReschedule({

const booking = await getBookingForReschedule(`${rescheduleUid}`, session?.user?.id);

if (booking?.eventType?.disableRescheduling) {
const userId = session?.user?.id;
const isHost = userId && booking?.user?.id === userId;

if (booking?.eventType?.disableRescheduling && !isHost) {
return {
redirect: {
destination: `/booking/${rescheduleUid}`,
Expand Down
7 changes: 6 additions & 1 deletion packages/features/bookings/lib/handleCancelBooking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,12 @@ async function handler(input: CancelBookingInput) {
throw new HttpError({ statusCode: 400, message: "User not found" });
}

if (bookingToDelete.eventType?.disableCancelling) {
const isHost =
(cancelledBy && bookingToDelete.user?.email === cancelledBy) ||
(userId !== -1 && bookingToDelete.userId === userId);

// Exempt hosts from disableCancelling restriction
if (bookingToDelete.eventType?.disableCancelling && !isHost) {
throw new HttpError({
statusCode: 400,
message: "This event type does not allow cancellations",
Expand Down