-
Notifications
You must be signed in to change notification settings - Fork 4
fix: handle collective multiple host on destinationCalendar #4
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
base: enhance-collective-scheduling-foundation
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -217,7 +217,8 @@ export const getBusyCalendarTimes = async ( | |
|
|
||
| export const createEvent = async ( | ||
| credential: CredentialWithAppName, | ||
| calEvent: CalendarEvent | ||
| calEvent: CalendarEvent, | ||
| externalId?: string | ||
| ): Promise<EventResult<NewCalendarEventType>> => { | ||
| const uid: string = getUid(calEvent); | ||
| const calendar = await getCalendar(credential); | ||
|
|
@@ -226,29 +227,31 @@ export const createEvent = async ( | |
|
|
||
| // Check if the disabledNotes flag is set to true | ||
| if (calEvent.hideCalendarNotes) { | ||
| calEvent.additionalNotes = "Notes have been hidden by the organiser"; // TODO: i18n this string? | ||
| calEvent.additionalNotes = "Notes have been hidden by the organizer"; // TODO: i18n this string? | ||
|
Contributor
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. 🛠️ Refactor suggestion Address the TODO: Internationalize this string. The spelling change to American English is fine, but as the TODO indicates, this string should be properly internationalized. Would you like me to help implement the internationalization for this string or create an issue to track it? 🤖 Prompt for AI Agents |
||
| } | ||
|
|
||
| // TODO: Surface success/error messages coming from apps to improve end user visibility | ||
| const creationResult = calendar | ||
| ? await calendar.createEvent(calEvent).catch(async (error: { code: number; calError: string }) => { | ||
| success = false; | ||
| /** | ||
| * There is a time when selectedCalendar externalId doesn't match witch certain credential | ||
| * so google returns 404. | ||
| * */ | ||
| if (error?.code === 404) { | ||
| ? await calendar | ||
| .createEvent(calEvent, credential.id) | ||
| .catch(async (error: { code: number; calError: string }) => { | ||
| success = false; | ||
| /** | ||
| * There is a time when selectedCalendar externalId doesn't match witch certain credential | ||
| * so google returns 404. | ||
| * */ | ||
| if (error?.code === 404) { | ||
| return undefined; | ||
| } | ||
| if (error?.calError) { | ||
| calError = error.calError; | ||
| } | ||
| log.error("createEvent failed", JSON.stringify(error), calEvent); | ||
| // @TODO: This code will be off till we can investigate an error with it | ||
| //https://github.com/calcom/cal.com/issues/3949 | ||
| // await sendBrokenIntegrationEmail(calEvent, "calendar"); | ||
| return undefined; | ||
| } | ||
| if (error?.calError) { | ||
| calError = error.calError; | ||
| } | ||
| log.error("createEvent failed", JSON.stringify(error), calEvent); | ||
| // @TODO: This code will be off till we can investigate an error with it | ||
| //https://github.com/calcom/cal.com/issues/3949 | ||
| // await sendBrokenIntegrationEmail(calEvent, "calendar"); | ||
| return undefined; | ||
| }) | ||
| }) | ||
| : undefined; | ||
|
|
||
| return { | ||
|
|
@@ -261,6 +264,8 @@ export const createEvent = async ( | |
| originalEvent: calEvent, | ||
| calError, | ||
| calWarnings: creationResult?.additionalInfo?.calWarnings || [], | ||
| externalId, | ||
| credentialId: credential.id, | ||
| }; | ||
| }; | ||
|
|
||
|
|
||
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.
Logic error in calendar selection for
updateEvent.The calendar extraction for organizer email is correct, but there's a logic issue at line 256:
The current logic will never find a match because you're searching for a calendar where
cal.externalId === externalCalendarIdwhenexternalCalendarIdis already provided. This appears to be attempting to validate theexternalCalendarId, but the logic is circular.Consider removing this redundant check:
const selectedCalendar = externalCalendarId ? externalCalendarId - : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; + : undefined;Or if you need to select a default calendar when
externalCalendarIdis not provided:Also applies to: 228-230, 254-256
🤖 Prompt for AI Agents