Skip to content

Commit

Permalink
Added Support for Declined Events
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo authored Oct 3, 2016
1 parent 1c71543 commit 5fb14fe
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions src/Code.gs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,26 @@ function checkIfBusy(id) {

} else { // go through the logic of determining which event (if any) should be returned

// build an array of event objects that are set to 'busy' status
// build an array of event objects that are set to 'busy' status that I'm attending
var busyEvents = [];

for (var i = 0; i < events.length; i++) {
for (var i in events) { // go through each event

var eventId = events[i].id;

var verboseEvent = Calendar.Events.get(id, eventId); // use the advanced calendar service to grab all the event's deets

if (!verboseEvent.transparency) { // if the event is 'busy', not 'available'
busyEvents.push(verboseEvent);

for (var j in verboseEvent.attendees) { // go through the attendees of the event to find "self"

if (verboseEvent.attendees[j].self && verboseEvent.attendees[j].responseStatus != "declined") { // check the "self" attendee and see if it's declined the event. If I haven't...

busyEvents.push(verboseEvent); // add the event to our array

}

}

}

}
Expand Down Expand Up @@ -92,7 +101,7 @@ function checkIfBusy(id) {

var selectedEvent = busyEvents[0]; // select the first busy event in the array

for (var i = 0; i < busyEvents.length; i++) { // go through each busy event
for (var i in busyEvents) { // go through each busy event

if (busyEvents[i].end.dateTime == null) { // (if there's an all-day/multi-day event, it may not have a dateTime... just a date)
busyEvents[i].end.dateTime = busyEvents[i].end.date + "T00:00:00-05:00"; // (this converts that date to a dateTime for the comparison below)
Expand Down

0 comments on commit 5fb14fe

Please sign in to comment.