googleapis / googleapis/google-api-nodejs-client
Google Calendar Webhooks with Node.js
- Lingua principale
- TypeScript
- Stelle
- 12.2k
- Fork
- 2k
- Merge medio
- 1g 9h
- PR unite (30g)
- 24
Descrizione
### What you're trying to do
- the goal is listening to the customer event response
### What is happening
- I made one implementation of push notifications using the google calendar API,
but all events are triggered when I make an update only in one event
- I'm creating all events using a main account and putting the customer as attendees in the creation process, for each event I have only one customer as an attendee, the goal is listening to the customer event response but when some customer responds to the event all, other events are triggered too and my endpoint receives calls from all events that I already create
### Calendar event creation code:
```
async createCalendarEvent(params: CalendarProvider.CreateEventParams) {
if (!this.calendar) return
try {
const event = {
summary: params.summary,
description: buildDescription({
eventName: params.eventName,
sessionDuration: params.sessionDuration,
sessionLink: params.sessionLink
}),
location: params.location,
start: {
dateTime: params.startDate,
timeZone: params.timezone
},
end: {
dateTime: params.endDate,
timeZone: params.timezone
},
...(params.recurrence && {
recurrence: buildRecurrence(params.recurrence)
}),
attendees: params.participants
}
const calendarEvent = await this.calendar.events.insert({
calendarId: DEFAULT_CALENDAR_ID,
requestBody: event
})
const watch = await this.calendar.events.watch({
requestBody: {
id: uuid4(),
type: 'web_hook',
address: `${this.webhookBaseEndpoint}/${calendarEvent.data.id}`
},
calendarId: DEFAULT_CALENDAR_ID
})
return calendarEvent?.data
} catch (error) {
console.log(error.response.data.error)
console.log(error)
Sentry.captureException(error)
}
}
```
### webhook endpoint code:
```
router.post('/calendar-webhook/:eventid', async (req, res) => {
try {
const eventId = req.params.eventid
await makeSyncCalendarResponse().sync({ eventId })
return res.sendStatus(200)
} catch (err) {
Sentry.captureException(err)
}
})
```
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Start with the createCalendarEvent method and the /calendar-webhook/:eventid endpoint shown in the issue, then read the Google Calendar push-notification behavior they rely on. Reproduce the notification flow with multiple events and determine the expected event scope; done means the reported cross-event triggering is explained and a focused fix or documented limitation is identified.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- node.js, typescript
- Ambito
- api, backend
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Da chiarire
- Idoneità per principianti
- 25/100