-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Test: fix/handle-collective-multiple-host-destinations #375
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 | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -84,7 +84,7 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| }; | ||||||||||||||
| }; | ||||||||||||||
|
|
||||||||||||||
| async createEvent(calEventRaw: CalendarEvent): Promise<NewCalendarEventType> { | ||||||||||||||
| async createEvent(calEventRaw: CalendarEvent, credentialId: number): Promise<NewCalendarEventType> { | ||||||||||||||
| const eventAttendees = calEventRaw.attendees.map(({ id: _id, ...rest }) => ({ | ||||||||||||||
| ...rest, | ||||||||||||||
| responseStatus: "accepted", | ||||||||||||||
|
|
@@ -97,6 +97,10 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| responseStatus: "accepted", | ||||||||||||||
| })) || []; | ||||||||||||||
| return new Promise(async (resolve, reject) => { | ||||||||||||||
| const [mainHostDestinationCalendar] = | ||||||||||||||
| calEventRaw?.destinationCalendar && calEventRaw?.destinationCalendar.length > 0 | ||||||||||||||
| ? calEventRaw.destinationCalendar | ||||||||||||||
| : []; | ||||||||||||||
| const myGoogleAuth = await this.auth.getToken(); | ||||||||||||||
| const payload: calendar_v3.Schema$Event = { | ||||||||||||||
| summary: calEventRaw.title, | ||||||||||||||
|
|
@@ -115,8 +119,8 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| id: String(calEventRaw.organizer.id), | ||||||||||||||
| responseStatus: "accepted", | ||||||||||||||
| organizer: true, | ||||||||||||||
| email: calEventRaw.destinationCalendar?.externalId | ||||||||||||||
| ? calEventRaw.destinationCalendar.externalId | ||||||||||||||
| email: mainHostDestinationCalendar?.externalId | ||||||||||||||
| ? mainHostDestinationCalendar.externalId | ||||||||||||||
| : calEventRaw.organizer.email, | ||||||||||||||
| }, | ||||||||||||||
| ...eventAttendees, | ||||||||||||||
|
|
@@ -138,13 +142,16 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| const calendar = google.calendar({ | ||||||||||||||
| version: "v3", | ||||||||||||||
| }); | ||||||||||||||
| const selectedCalendar = calEventRaw.destinationCalendar?.externalId | ||||||||||||||
| ? calEventRaw.destinationCalendar.externalId | ||||||||||||||
| : "primary"; | ||||||||||||||
| // Find in calEventRaw.destinationCalendar the one with the same credentialId | ||||||||||||||
|
|
||||||||||||||
| const selectedCalendar = calEventRaw.destinationCalendar?.find( | ||||||||||||||
| (cal) => cal.credentialId === credentialId | ||||||||||||||
| )?.externalId; | ||||||||||||||
|
|
||||||||||||||
| calendar.events.insert( | ||||||||||||||
| { | ||||||||||||||
| auth: myGoogleAuth, | ||||||||||||||
| calendarId: selectedCalendar, | ||||||||||||||
| calendarId: selectedCalendar || "primary", | ||||||||||||||
| requestBody: payload, | ||||||||||||||
| conferenceDataVersion: 1, | ||||||||||||||
| sendUpdates: "none", | ||||||||||||||
|
|
@@ -188,6 +195,8 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
|
|
||||||||||||||
| async updateEvent(uid: string, event: CalendarEvent, externalCalendarId: string): Promise<any> { | ||||||||||||||
| return new Promise(async (resolve, reject) => { | ||||||||||||||
| const [mainHostDestinationCalendar] = | ||||||||||||||
| event?.destinationCalendar && event?.destinationCalendar.length > 0 ? event.destinationCalendar : []; | ||||||||||||||
| const myGoogleAuth = await this.auth.getToken(); | ||||||||||||||
| const eventAttendees = event.attendees.map(({ ...rest }) => ({ | ||||||||||||||
| ...rest, | ||||||||||||||
|
|
@@ -216,8 +225,8 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| id: String(event.organizer.id), | ||||||||||||||
| organizer: true, | ||||||||||||||
| responseStatus: "accepted", | ||||||||||||||
| email: event.destinationCalendar?.externalId | ||||||||||||||
| ? event.destinationCalendar.externalId | ||||||||||||||
| email: mainHostDestinationCalendar?.externalId | ||||||||||||||
| ? mainHostDestinationCalendar.externalId | ||||||||||||||
| : event.organizer.email, | ||||||||||||||
| }, | ||||||||||||||
| ...(eventAttendees as any), | ||||||||||||||
|
|
@@ -244,7 +253,7 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
|
|
||||||||||||||
| const selectedCalendar = externalCalendarId | ||||||||||||||
| ? externalCalendarId | ||||||||||||||
| : event.destinationCalendar?.externalId; | ||||||||||||||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; | ||||||||||||||
|
Comment on lines
254
to
+256
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. 🧩 Analysis chain🏁 Script executed: # First, let's see the context around lines 254-256 in the current file
head -300 packages/app-store/googlecalendar/lib/CalendarService.ts | tail -100Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 3311 🏁 Script executed: # Check the git history for the old implementation
git log --oneline -20 -- packages/app-store/googlecalendar/lib/CalendarService.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 168 🏁 Script executed: # Search for calls to updateEvent to see if externalCalendarId is always provided
rg "updateEvent" --type ts -B 2 -A 2 packages/Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 11261 🏁 Script executed: # Get the commit that introduced this change
git show bd797c1ea --stat | head -50Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 3015 🏁 Script executed: # Look at lines 315-317 (deleteEvent) to compare
sed -n '310,325p' packages/app-store/googlecalendar/lib/CalendarService.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 599 🏁 Script executed: # Check if there's a fallback to "primary" in deleteEvent
sed -n '315,330p' packages/app-store/googlecalendar/lib/CalendarService.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror Length of output: 689 Bug: tautological fallback — When The intended logic was likely to fall back to the main host's destination calendar (destructured at line 100-103), similar to the pattern in Note: 🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| calendar.events.update( | ||||||||||||||
| { | ||||||||||||||
|
|
@@ -303,7 +312,9 @@ export default class GoogleCalendarService implements Calendar { | |||||||||||||
| }); | ||||||||||||||
|
|
||||||||||||||
| const defaultCalendarId = "primary"; | ||||||||||||||
| const calendarId = externalCalendarId ? externalCalendarId : event.destinationCalendar?.externalId; | ||||||||||||||
| const calendarId = externalCalendarId | ||||||||||||||
| ? externalCalendarId | ||||||||||||||
| : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId; | ||||||||||||||
|
Comment on lines
+315
to
+317
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. Same tautological fallback bug as Identical issue: when Still, the Proposed fix const calendarId = externalCalendarId
? externalCalendarId
- : event.destinationCalendar?.find((cal) => cal.externalId === externalCalendarId)?.externalId;
+ : event.destinationCalendar?.find((cal) => cal.credentialId)?.externalId;📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||
|
|
||||||||||||||
| calendar.events.delete( | ||||||||||||||
| { | ||||||||||||||
|
|
||||||||||||||
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.
🧩 Analysis chain
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 472
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 573
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 3606
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 666
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 345
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 841
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1708
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1094
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1785
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 72
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 72
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 2538
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1358
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 2345
🏁 Script executed:
Repository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1972
🏁 Script executed:
# Check which calendar implementation is loaded by getCalendar cat -n packages/app-store/_utils/getCalendar.tsRepository: admin-coderabbit/coderabbit-cal_dot_com-mirror
Length of output: 1972
Update all calendar provider implementations to match the interface signature with
credentialIdparameter.The
Calendarinterface inpackages/types/Calendar.d.tsrequirescreateEvent(event: CalendarEvent, credentialId: number), andGoogleCalendarServicecorrectly implements this. However, 12+ other calendar implementations still have the old signature withoutcredentialId:office365calendar,larkcalendar,zoho-bigin,zohocrm,sendgrid,salesforce,exchangecalendar,exchange2013,exchange2016,hubspot,closecom, andbasecamp3. These violate the interface contract and must be updated to include thecredentialIdparameter.🤖 Prompt for AI Agents