Created
October 1, 2018 08:39
-
-
Save C5H8NNaO4/51e427520e3c2ba7a04ece7770f8da88 to your computer and use it in GitHub Desktop.
Set all your Office365 appointments sensitivity to private
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
CALENDAR_VIEW = '//' + location.host + "/api/v2.0/me/calendarview?startDateTime=1970-01-01T00:00:00Z&endDateTime=2111-10-28T13:03:38.168Z&$select=Subject" | |
async function turnPrivate (entry) { | |
let options = { | |
method: 'PATCH', | |
headers: new Headers ({ | |
"Content-Type": "application/json" | |
}), | |
body: JSON.stringify ({ | |
Sensitivity: "2" | |
}) | |
} | |
return await (await fetch (entry["@odata.id"], options)).json () | |
} | |
async function fetchEvent (id) { | |
return await (await fetch (id)).json () | |
} | |
async function turnAllEventsPrivate () { | |
let res = await fetch ( CALENDAR_VIEW, {withCredentials: true}) | |
return await Promise.all ( | |
(await Promise.all ( | |
(await res.json ()).value | |
.map ((cal) => cal["@odata.id"]) | |
.map (fetchEvent) | |
)).map (turnPrivate) | |
) | |
} | |
(await turnAllEventsPrivate()).map (({Sensitivity, Subject}) => `${Subject}: ${Sensitivity}`) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment