derekantrican / GAS-ICS-Sync

A Google Apps Script for syncing ICS/ICAL files faster than the current Google Calendar speed
GNU General Public License v3.0
1.54k stars 197 forks source link

Convert Safe Links, Add option for default reminder #172

Open tjuwin1 opened 3 years ago

tjuwin1 commented 3 years ago
  1. When meeting invites are forwarded from Outlook, hyperlinks (for Teams/Webex meetings) are masked by adding safelinks.protection.outlook.com prefix on them and forces the links to be opened via certain apps only.

E.g: \nLearn More<https://aka.ms/JoinTeamsMeeting> | Meeting options<https://ap c01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fteams.microsoft.co m%2FmeetingOptions%2F%3ForganizerId%3D86e02103-9c5b-4e5f-9

I used this additional function to replace safelinks server name with google.com

function updateSafelinks(linkData){ var matcherUrl = new RegExp('https:\/\/.*?safelinks.protection.outlook.com\\/.*?\\\?url=','g'); linkData = linkData.replace(matcherUrl,"https://www.google.com/url?q="); return linkData; }

This is called from createEvent

if (descriptionAsTitles && event.hasProperty('description')) var eventSummary = updateSafelinks(icalEvent.description); else if (event.hasProperty('summary')) eventSummary = updateSafelinks(icalEvent.summary);

  1. When sharing calendar from Outlook (https://docs.microsoft.com/en-us/outlook/troubleshoot/calendaring/how-to-share-calendar-and-contacts#what-do-you-want-to-share), it removes all reminders from all meetings. Hence, I added a 5min default reminder to all my events by having this logic in createEvent:

if (valarms.length > 0){ .... }else{ var overrides = []; overrides.push({'method' : 'popup', 'minutes' : 5}); newEvent.reminders = { 'useDefault' : false, 'overrides' : overrides }; }

Please add these enhancements to the original scripts, if found useful.

derekantrican commented 3 years ago
  1. Why are you appending "https://www.google.com/url?q=" to the safelink? Can't you just take out the "safelinks..." prefix, then decode the rest of the url? I would suggest something like:
function updateSafelinks(linkData){
  var matcherUrl = new RegExp('https:\/\/.*?safelinks.protection.outlook.com\\/.*?\\\?url=','g');
  linkData = decodeURIComponent(linkData.replace(matcherUrl,""));
  return linkData;
}

Otherwise, it seems like an acceptable add to the script. Make this change and start a PR - I'll take a look at it.

  1. The link you provided doesn't seem to clearly say "all reminders are removed from meetings when sharing from Outlook" (and a quick Google search doesn't show me anything to that effect - so it at least isn't well known). But, regardless, I think this is a change to be made on a user-by-user basis and not to put into the main script