Skip to content

Commit

Permalink
sync presentations
Browse files Browse the repository at this point in the history
  • Loading branch information
wslyvh committed Oct 28, 2024
1 parent 9eaea28 commit 171d71c
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 16 deletions.
53 changes: 38 additions & 15 deletions devcon-api/src/clients/slides.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ const SCOPES = ['https://www.googleapis.com/auth/presentations', 'https://www.go
const DRIVE_ID = '0AJsI-Zeg-2IbUk9PVA'
const FOLDER_ID = '1IXkffNcDyycQe5Cxrc9Dtirgw1WitV1j'
const TEMPLATE_ID = '1pDxePJwWHpzIxIjl3OZVnkS9N_tBQKRfg57PeEkTqeU'
const sendEmail = true
const skipPermissions = false
const emailMessage = 'Your Devcon 7 presentation'

let client: GoogleApis | null = null
Expand Down Expand Up @@ -84,22 +84,45 @@ export async function CreatePresentationFromTemplate(title: string, id: string,
return
}

console.log('Setting permissions...')
for (const email of emails) {
await drive.permissions.create({
fileId: presentationId,
supportsAllDrives: true,
requestBody: {
type: 'user',
role: 'writer',
emailAddress: email,
},
sendNotificationEmail: sendEmail,
emailMessage: sendEmail && emailMessage ? emailMessage : undefined,
})
console.log('Presentation created', `https://docs.google.com/presentation/d/${presentationId}`)
if (skipPermissions) {
console.log('Skip permissions. Grant manually:', emails.join(', '))
} else {
for (const email of emails) {
try {
// No notification email
await drive.permissions.create({
fileId: presentationId,
supportsAllDrives: true,
requestBody: {
type: 'user',
role: 'writer',
emailAddress: email,
},
sendNotificationEmail: false,
})
} catch (e) {
try {
// Rate-limited
await drive.permissions.create({
fileId: presentationId,
supportsAllDrives: true,
requestBody: {
type: 'user',
role: 'writer',
emailAddress: email,
},
sendNotificationEmail: true,
emailMessage: emailMessage,
})
} catch (e) {
console.log('Error setting permissions. Grant manually:', emails.join(', '))
}
}
}
}

console.log('Presentation created', `https://docs.google.com/presentation/d/${presentationId}`)
console.log()
return presentationId
} catch (e) {
console.log('Error create presentation from template', TEMPLATE_ID, id, title)
Expand Down
2 changes: 1 addition & 1 deletion devcon-api/src/scripts/sync-pretalx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ async function main() {
console.log('Syncing Pretalx...')
await syncRooms()
await syncSessions()
// await createPresentations()
await createPresentations()
}

async function syncRooms() {
Expand Down

0 comments on commit 171d71c

Please sign in to comment.