[WIP] ✨ feat(sub-calendars): watch google calendar for updates#1102
[WIP] ✨ feat(sub-calendars): watch google calendar for updates#1102victor-enogwe wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR adds real-time Google Calendar list synchronization via push notification webhooks. When a user's list of calendars changes (calendars added/removed), the system will be notified automatically instead of polling.
Key Changes:
- Added
startWatchingGcalCalendarsmethod to monitor calendar list changes - Introduced
isWatchingCalendarsquery to check if calendar list is already being watched - Distinguished event watches from calendar watches with separate error types and channel ID suffixes
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| packages/backend/src/sync/util/sync.queries.ts | Added query to check if calendar list is being watched |
| packages/backend/src/sync/services/sync.service.ts | Implemented calendar list watch setup and updated event watch error messages |
| packages/backend/src/common/services/gcal/gcal.service.ts | Added Google Calendar List watch method and suffixed channel IDs |
| packages/backend/src/common/errors/sync/sync.errors.ts | Split watch error types for events vs calendars |
| "google.calendarlist.$.channelId": { $exists: true }, | ||
| "google.calendarlist.$.expiration": { $exists: true }, |
There was a problem hiding this comment.
The $ positional operator requires a matching array field in the query, but google.calendarlist is not being queried as an array. This will cause the query to fail. Consider using dot notation like 'google.calendarlist.channelId' instead, or if this is an array field, add an array element match condition.
| "google.calendarlist.$.channelId": { $exists: true }, | |
| "google.calendarlist.$.expiration": { $exists: true }, | |
| "google.calendarlist": { | |
| $elemMatch: { | |
| channelId: { $exists: true }, | |
| expiration: { $exists: true }, | |
| } | |
| } |
| throw error(SyncError.NoResourceId, "Calendar Watch Failed"); | ||
| } | ||
|
|
||
| const sync = await updateSync(Resource_Sync.CALENDAR, userId, null, { |
There was a problem hiding this comment.
Passing null as the gCalendarId parameter will cause issues in updateSync since it tries to match e.gCalendarId === gCalendarId (line would compare to null) and uses it in the operation. The function expects a string for proper array element matching and updates. Consider modifying updateSync to handle calendar list watches differently, or create a separate update function for this resource type.
|
Closing this PR as it has an implementation using the outdates watch schema. |
What does this PR do?
adds realtime updates to the user's google calendars via a google push notificiation webhooks.
Use Case
closes #1070