Skip to content
This repository has been archived by the owner on Dec 7, 2023. It is now read-only.

fix: Update Code.js to account for changes from Calendar API #238

Merged
merged 1 commit into from
Dec 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions vacation-calendar/src/Code.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,32 @@ function sync() {
* calendar.
* @param {string} username The team member that is attending the event.
* @param {Calendar.Event} event The event to import.
* @return {boolean} True if the event was imported.
*/
function importEvent(username, event) {
event.summary = '[' + username + '] ' + event.summary;
event.organizer = {
id: TEAM_CALENDAR_ID,
};
event.attendees = [];

// If the event is not of type 'default', it can't be imported, so it needs
// to be changed.
if (event.eventType != 'default') {
event.eventType = 'default';
delete event.outOfOfficeProperties;
delete event.focusTimeProperties;
}

console.log('Importing: %s', event.summary);
try {
Calendar.Events.import(event, TEAM_CALENDAR_ID);
return true;
} catch (e) {
console.error('Error attempting to import event: %s. Skipping.',
e.toString());
return false;
}
}


/**
* In a given user's calendar, look for occurrences of the given keyword
* in events within the specified date range and return any such events
Expand Down
Loading