Skip to content
Open
Show file tree
Hide file tree
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
4 changes: 3 additions & 1 deletion Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ var defaultAllDayReminder = -1; // Default reminder for all day events
// See https://github.com/derekantrican/GAS-ICS-Sync/issues/75 for why this is neccessary.
var overrideVisibility = ""; // Changes the visibility of the event ("default", "public", "private", "confidential"). Anything else will revert to the class value of the ICAL event.
var addTasks = false;
var overrideEventDetails = true; // If set to true, the script will strip details (description, location, attendees) and rename the event.
var overrideEventTitle = "Busy"; // The event title to use when overrideEventDetails is set to true.

var emailSummary = false; // Will email you when an event is added/modified/removed to your calendar
var email = ""; // OPTIONAL: If "emailSummary" is set to true or you want to receive update notifications, you will need to provide your email address
Expand Down Expand Up @@ -253,4 +255,4 @@ function startSync(){
// (the message text does not seem to be logged anywhere)
throw new Error('The sync operation produced errors. See log for details.');
}
}
}
36 changes: 25 additions & 11 deletions Helpers.gs
Original file line number Diff line number Diff line change
Expand Up @@ -322,15 +322,15 @@ function filterResults(events){
events[indx].getFirstProperty('exdate').setValues(exdates);
}
return result;
}
}
}
catch(e){
Logger.log(e);
return (filter.type == "exclude");
}
});
}

Logger.log(`${events.length} events left.`);
return events;
}
Expand Down Expand Up @@ -496,7 +496,7 @@ function modifyRecurrenceStart(event, referenceDate, filterParameter) {
continue;
}
}

newStartDate = next;
break;
}
Expand Down Expand Up @@ -656,7 +656,10 @@ function createEvent(event, calendarTz){
event.removeProperty('dtstamp');
var icalEvent = new ICAL.Event(event);

var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, icalEvent.toString(), Utilities.Charset.UTF_8).toString();
// --- Added so toggling the overrideEventDetails feature triggers an update ---
var signature = icalEvent.toString() + "|" + overrideEventDetails + "|" + overrideEventTitle;
var digest = Utilities.computeDigest(Utilities.DigestAlgorithm.MD5, signature, Utilities.Charset.UTF_8).toString();

if(calendarEventsMD5s.indexOf(digest) >= 0){
Logger.log("Skipping unchanged Event " + event.getFirstPropertyValue('uid').toString());
return;
Expand Down Expand Up @@ -854,6 +857,17 @@ function createEvent(event, calendarTz){
}; //else unsupported value
}

// --- Privacy logic to strip details ---
if (overrideEventDetails) {
Logger.log("ACTION: Stripping details for event and renaming to '" + overrideEventTitle + "'");
newEvent.summary = overrideEventTitle;
newEvent.description = "";
newEvent.location = "";
newEvent.attendees = [];
delete newEvent.organizer;
delete newEvent.source;
}

return newEvent;
}

Expand Down Expand Up @@ -920,12 +934,12 @@ function processEventCleanup(){
var currentID = calendarEventsIds[i];
var feedIndex = icsEventsIds.indexOf(currentID);

if(feedIndex == -1 // Event is no longer in source
&& calendarEvents[i].recurringEventId == null // And it's not a recurring event
&& ( // And one of:
removePastEventsFromCalendar // We want to remove past events
|| new Date(calendarEvents[i].start.dateTime) > new Date() // Or the event is in the future
|| new Date(calendarEvents[i].start.date) > new Date() // (2 different ways event start can be stored)
if(feedIndex == -1 // Event is no longer in source
&& calendarEvents[i].recurringEventId == null // And it's not a recurring event
&& ( // And one of:
removePastEventsFromCalendar // We want to remove past events
|| new Date(calendarEvents[i].start.dateTime) > new Date() // Or the event is in the future
|| new Date(calendarEvents[i].start.date) > new Date() // (2 different ways event start can be stored)
)
)
{
Expand Down Expand Up @@ -1312,7 +1326,7 @@ function callWithBackoff(func, maxRetries) {
} else {
Logger.log( "Error, Retrying... [" + err +"]");
Utilities.sleep (Math.pow(2,tries)*100) +
(Math.round(Math.random() * 100));
(Math.round(Math.random() * 100));
}
}
}
Expand Down