fix: selected organizer when creating event (#11157)

This commit is contained in:
alannnc authored and GitHub committed 2023-09-05 13:38:59 -07:00
1 parent d34db7aef6
commit 6dd0f9ce29
1 file changed
+5 -6
@@ -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,