-
Notifications
You must be signed in to change notification settings - Fork 0
/
Events.gs
57 lines (53 loc) · 1.48 KB
/
Events.gs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
function copyEventSummary(event) {
if (event.visibility == 'private' || event.visibility == undefined && default_very_private) {
return eventPrefix;//+" (Private)";
} else {
return eventPrefix+" ("+event.summary+")";
}
}
function copyEventDescription(event) {
if (event.visibility == "public" && default_very_private) {
return "";
} else {
return event.description;
}
}
function copyEvent(event) {
var data = {
summary: copyEventSummary(event),
// location: 'The Deli',
description: copyEventDescription(event),
start: {
dateTime: event.start.dateTime,//.toISOString()
date: event.start.date
},
end: {
dateTime: event.end.dateTime,//.toISOString()
date: event.end.date
},
// Red background. Use Calendar.Colors.get() for the full list.
colorId: color,
reminders: {
useDefault: false,
overrides: []
},
extendedProperties: {
shared: {}
},
transparency: event.transparency || "opaque", // Free/Busy — defaults to "opaque" (busy)
visibility: 'private'
};
data.extendedProperties.shared[calendarId] = event.id
debug(JSON.stringify(data));
return data;
}
function createEvent(sEvent, calendar) {
var eventData = copyEvent(sEvent);
return Calendar.Events.insert(eventData, calendar.getId());
}
function updateEvent(pEvent, sEvent) {
var updates = copyEvent(sEvent);
retry(3, function() {
Calendar.Events.patch(updates, primaryCalendar.getId(), pEvent.id);
});
}