googleapis / googleapis/google-api-nodejs-client

Google Calendar Webhooks with Node.js

Offen
#3,158 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
priority: p3 type: question
Vorherrschende Sprache
TypeScript
Sterne
12.2k
Forks
2k
Ø Merge
1 T. 9 Std.
Gemergte PRs (30 T.)
24

Beschreibung

### 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)
}
})
```

Beitragsleitfaden

Beitragsleitfaden öffnen

Rechercherichtung

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.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
node.js, typescript
Bereich
api, backend
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Muss geklärt werden
Anfängerfreundlichkeit
25/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.