-
Notifications
You must be signed in to change notification settings - Fork 7.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Broken reschedule page for migrated user's booking through request-reschedule #16068
Merged
Merged
Changes from 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
b877ad2
fix: Fix URL send in request-reschedule email
hariombalhara 6ea7e7c
Fix test and remove silly logs
hariombalhara 68adc77
feat: Add rescheduledBy & canceledBy fields in the DB (#15337)
Amit91848 20fe19c
fix: Fix URL send in request-reschedule email
hariombalhara 731e431
refactor: more feedback
zomars 657f1ba
Discard changes to packages/prisma/schema.prisma
zomars cb09f8e
Update director.ts
zomars 524ba48
Update director.ts
zomars d5841d5
Update builder.ts
zomars File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -143,10 +143,9 @@ expect.extend({ | |
|
||
if (!isEmailContentMatched) { | ||
logger.silly("All Emails", JSON.stringify({ numEmails: emailsToLog.length, emailsToLog })); | ||
|
||
return { | ||
pass: false, | ||
message: () => `Email content ${isNot ? "is" : "is not"} matching. ${JSON.stringify(emailsToLog)}`, | ||
message: () => `Email content ${isNot ? "is" : "is not"} matching.`, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reduce the noise. emailToLog could be huge |
||
actual: actualEmailContent, | ||
expected: expectedEmailContent, | ||
}; | ||
|
@@ -818,8 +817,6 @@ export function expectBookingRequestRescheduledEmails({ | |
loggedInUser, | ||
booker, | ||
booking, | ||
bookNewTimePath, | ||
organizer, | ||
}: { | ||
emails: Fixtures["emails"]; | ||
organizer: ReturnType<typeof getOrganizer>; | ||
|
@@ -840,7 +837,7 @@ export function expectBookingRequestRescheduledEmails({ | |
subHeading: "request_reschedule_subtitle", | ||
links: [ | ||
{ | ||
href: `${bookingUrlOrigin}${bookNewTimePath}?rescheduleUid=${booking.uid}`, | ||
href: `${bookingUrlOrigin}/reschedule/${booking.uid}?allowRescheduleForCancelledBooking=true`, | ||
text: "Book a new time", | ||
}, | ||
], | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,9 @@ | ||
import type { Booking } from "@prisma/client"; | ||
import { Prisma } from "@prisma/client"; | ||
import short from "short-uuid"; | ||
import { v5 as uuidv5 } from "uuid"; | ||
|
||
import dayjs from "@calcom/dayjs"; | ||
import { WEBAPP_URL } from "@calcom/lib/constants"; | ||
import { getRescheduleLink } from "@calcom/lib/CalEventParser"; | ||
import logger from "@calcom/lib/logger"; | ||
import { safeStringify } from "@calcom/lib/safeStringify"; | ||
import { getTranslation } from "@calcom/lib/server/i18n"; | ||
|
@@ -238,32 +237,16 @@ export class CalendarEventBuilder implements ICalendarEventBuilder { | |
} | ||
} | ||
|
||
public buildRescheduleLink(booking: Partial<Booking>, eventType?: CalendarEventBuilder["eventType"]) { | ||
public buildRescheduleLink({ | ||
allowRescheduleForCancelledBooking = false, | ||
}: { | ||
allowRescheduleForCancelledBooking?: boolean; | ||
}) { | ||
try { | ||
if (!booking) { | ||
throw new Error("Parameter booking is required to build reschedule link"); | ||
} | ||
const isTeam = !!eventType && !!eventType.teamId; | ||
const isDynamic = booking?.dynamicEventSlugRef && booking?.dynamicGroupSlugRef; | ||
|
||
let slug = ""; | ||
if (isTeam && eventType?.team?.slug) { | ||
slug = `team/${eventType.team?.slug}/${eventType.slug}`; | ||
} else if (isDynamic) { | ||
const dynamicSlug = isDynamic ? `${booking.dynamicGroupSlugRef}/${booking.dynamicEventSlugRef}` : ""; | ||
slug = dynamicSlug; | ||
} else if (eventType?.slug) { | ||
slug = `${this.users[0].username}/${eventType.slug}`; | ||
} | ||
|
||
const queryParams = new URLSearchParams(); | ||
queryParams.set("rescheduleUid", `${booking.uid}`); | ||
slug = `${slug}`; | ||
|
||
const rescheduleLink = `${ | ||
this.calendarEvent.bookerUrl ?? WEBAPP_URL | ||
}/${slug}?${queryParams.toString()}`; | ||
this.rescheduleLink = rescheduleLink; | ||
this.rescheduleLink = getRescheduleLink({ | ||
calEvent: this.calendarEvent, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Reused existing reschedule link generator. This fixes the bug. |
||
allowRescheduleForCancelledBooking, | ||
}); | ||
} catch (error) { | ||
if (error instanceof Error) { | ||
throw new Error(`buildRescheduleLink.error: ${error.message}`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove the noise in tests. Can be enabled on demand