Created
July 12, 2017 18:12
-
-
Save dzuelke/86670b846ce8d176b279c149d90f92c3 to your computer and use it in GitHub Desktop.
Google Apps Script that handles Hangout/Meet links, with automatic updates and primary calendar detection. See https://medium.com/@JoeSalowitz/how-to-add-google-calendar-hangouts-links-to-mac-and-ios-calendar-events-af365cd93a3c for original post.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function moveHangoutLinks() { | |
var calendarId = Calendar.Calendars.get('primary').id; | |
var now = new Date(); | |
var events = Calendar.Events.list(calendarId, { | |
timeMin: now.toISOString(), | |
singleEvents: true, | |
orderBy: 'startTime', | |
maxResults: 10 | |
}); | |
if (events.items && events.items.length > 0) { | |
for (var i = 0; i < events.items.length; i++) { | |
var event = events.items[i]; | |
if (event.hangoutLink) { | |
hangoutUrl = event.hangoutLink + (event.hangoutLink.indexOf('?') == -1 ? '?' : '&') + 'authuser=' + calendarId; | |
event.description = (event.description || '').replace(/^Hangout(\/Meet)?:.+$[\s]+/mg, 'Hangout/Meet: ' + hangoutUrl + '\n\n'); | |
Calendar.Events.update(event, calendarId, event.id); | |
} | |
} | |
} else { | |
Logger.log('No events found.'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment