Skip to content

Conversation

@victor-enogwe
Copy link
Contributor

What does this PR do?

adds realtime updates to the user's google calendars via a google push notificiation webhooks.

Use Case

closes #1070

Copilot AI review requested due to automatic review settings October 13, 2025 14:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 startWatchingGcalCalendars method to monitor calendar list changes
  • Introduced isWatchingCalendars query 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

Comment on lines +191 to +192
"google.calendarlist.$.channelId": { $exists: true },
"google.calendarlist.$.expiration": { $exists: true },
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
"google.calendarlist.$.channelId": { $exists: true },
"google.calendarlist.$.expiration": { $exists: true },
"google.calendarlist": {
$elemMatch: {
channelId: { $exists: true },
expiration: { $exists: true },
}
}

Copilot uses AI. Check for mistakes.
throw error(SyncError.NoResourceId, "Calendar Watch Failed");
}

const sync = await updateSync(Resource_Sync.CALENDAR, userId, null, {
Copy link

Copilot AI Oct 13, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@victor-enogwe victor-enogwe changed the title ✨ feat(sub-calendars): watch cal list WIP [WIP] ✨ feat(sub-calendars): watch google calendar for updates Oct 13, 2025
@victor-enogwe
Copy link
Contributor Author

Closing this PR as it has an implementation using the outdates watch schema.
This story will be re-done in a new PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Watch for Google calendar changes

2 participants