Skip to content

Instantly share code, notes, and snippets.

@C5H8NNaO4
Created October 1, 2018 08:39
Show Gist options
  • Save C5H8NNaO4/51e427520e3c2ba7a04ece7770f8da88 to your computer and use it in GitHub Desktop.
Save C5H8NNaO4/51e427520e3c2ba7a04ece7770f8da88 to your computer and use it in GitHub Desktop.
Set all your Office365 appointments sensitivity to private
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