Skip to content
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

On event updated #280

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
12 changes: 12 additions & 0 deletions Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ var sourceCalendars = [ // The ics/ical urls that you want to get

];

var addUpdateTrigger = false; // EXPERIMENTAL: use Google Calendar native "onEventUpdated" trigger
var sourceCalendarOwners = [ // EXPERIMENTAL: list of email addresses of sourceCalendars owners, to set "onEventUpdated" triggers
"[email protected]"
];

var howFrequent = 15; // What interval (minutes) to run this script on to check for new events
var onlyFutureEvents = false; // If you turn this to "true", past events will not be synced (this will also removed past events from the target calendar if removeEventsFromCalendar is true)
var addEventsToCalendar = true; // If you turn this to "false", you can check the log (View > Logs) to make sure your events are being read correctly before turning this on
Expand Down Expand Up @@ -104,6 +109,13 @@ function install(){
ScriptApp.newTrigger("startSync").timeBased().everyMinutes(getValidTriggerFrequency(howFrequent)).create();
ScriptApp.newTrigger("startSync").timeBased().after(1000).create();

//Add push trigger if enabled
if (addUpdateTrigger) {
sourceCalendarOwners.forEach(ownerEmail =>
ScriptApp.newTrigger("startSync").forUserCalendar(ownerEmail).onEventUpdated().create()
)
}

//Schedule sync routine to look for update once per day
ScriptApp.newTrigger("checkForUpdate").timeBased().everyDays(1).create();
}
Expand Down