Skip to content

Commit

Permalink
feat: Add recurrence to GCal events
Browse files Browse the repository at this point in the history
  • Loading branch information
Dschoordsch committed Jan 23, 2024
1 parent 9d71265 commit e82ef57
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 5 deletions.
20 changes: 16 additions & 4 deletions packages/server/graphql/mutations/helpers/createGcalEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ type Input = {
meetingId: string
viewerId: string
teamId: string
rrule?: string | null
dataLoader: DataLoaderWorker
}

const createGcalEvent = async (input: Input) => {
const {gcalInput, meetingId, viewerId, dataLoader, teamId} = input
const {gcalInput, meetingId, viewerId, dataLoader, teamId, rrule} = input
if (!gcalInput) {
return {error: null}
}
Expand Down Expand Up @@ -57,8 +58,17 @@ const createGcalEvent = async (input: Input) => {
}
}
: undefined
const recurrence = rrule
? [
rrule
.split('\n')
.filter((line) => !line.startsWith('DTSTART') && !line.startsWith('DTEND'))
.join('\n')
]
: undefined
console.log('GEORG RECURRENCE', recurrence)

const event = {
const eventInput = {
summary: title,
description,
start: {
Expand All @@ -69,6 +79,7 @@ const createGcalEvent = async (input: Input) => {
dateTime: endDateTime,
timeZone
},
recurrence,
attendees: attendeesWithEmailObjects,
reminders: {
useDefault: false,
Expand All @@ -81,11 +92,12 @@ const createGcalEvent = async (input: Input) => {
}

try {
await calendar.events.insert({
const event = await calendar.events.insert({
calendarId: 'primary',
requestBody: event,
requestBody: eventInput,
conferenceDataVersion: 1
})
console.log('GEORG EVENT', event)
} catch (err) {
const error = err instanceof Error ? err : new Error('Unable to create event in gcal')
return standardError(error, {userId: viewerId})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,14 @@ const startRetrospective: MutationResolvers['startRetrospective'] = async (
}
IntegrationNotifier.startMeeting(dataLoader, meetingId, teamId)
analytics.meetingStarted(viewer, meeting, template)
const {error} = await createGcalEvent({gcalInput, meetingId, teamId, viewerId, dataLoader})
const {error} = await createGcalEvent({
gcalInput,
meetingId,
teamId,
viewerId,
rrule: meetingSeries?.recurrenceRule,
dataLoader
})
const data = {teamId, meetingId, hasGcalError: !!error?.message}
publish(SubscriptionChannel.TEAM, teamId, 'StartRetrospectiveSuccess', data, subOptions)
return data
Expand Down

0 comments on commit e82ef57

Please sign in to comment.