Skip to content

Scheduling infrastructure for absolutely everyone.

fix: selected organizer when creating event (#11157)

alannnc6dd0f9ce29e1
diff --git a/packages/app-store/googlecalendar/lib/CalendarService.ts b/packages/app-store/googlecalendar/lib/CalendarService.ts
index e0b98b2ca00..23d10c8dbe4 100644
--- a/packages/app-store/googlecalendar/lib/CalendarService.ts
+++ b/packages/app-store/googlecalendar/lib/CalendarService.ts
@@ -97,10 +97,9 @@ 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 selectedHostDestinationCalendar = calEventRaw.destinationCalendar?.find(
+ (cal) => cal.credentialId === credentialId
+ );
const myGoogleAuth = await this.auth.getToken();
const payload: calendar_v3.Schema$Event = {
summary: calEventRaw.title,
@@ -119,8 +118,8 @@ export default class GoogleCalendarService implements Calendar {
id: String(calEventRaw.organizer.id),
responseStatus: "accepted",
organizer: true,
- email: mainHostDestinationCalendar?.externalId
- ? mainHostDestinationCalendar.externalId
+ email: selectedHostDestinationCalendar?.externalId
+ ? selectedHostDestinationCalendar.externalId
: calEventRaw.organizer.email,
},
...eventAttendees,