This PR implements the functionality to -
fetchAvailabilityAndSetCache()
is called for above outlook calendars to update the calendar-cache.watch
and unwatch
functionality is implemented through Microsoft Graph APIs /subscribe , so that the existing cron job can start to subscribe or unsubscribe based on conditions (to avoid duplicate subscriptions).Key points:
Visit the team public page with cal.cache
query parameter set to true, to see the Cache effect or see [Cache Hit] in logs for office365_calendar.
Example : http://localhost:3000/team/devs/teamevent?overlayCalendar=true&layout=month_view&cal.cache=true
In this PR, the startWatchingCalendarInMicrosoft()
calls /subscription endpoint targeting specific calendars. This avoids subscribing to overly broad resources (e.g., me/events for all calendar events). Instead, target specific calendars or folders (e.g., me/calendars/{calendar_id}/events) to reduce notification volume.
Next Steps or Improvements for scaling Given the volume of usage, if we have very high number of teams, team members, team events, simultaneously updating events in outlook - the volume of subscriptions received by the web-hook can be overwhelming even with load balancers.
We can consider Asynchronous Processing: Process notifications asynchronously to avoid blocking the webhook endpoint. For example, queue incoming notifications (using a cloud message queuing system like AWS SQS or RabbitMQ or Azure Queue Storage) and process them in the background with worker nodes. This ensures the endpoint remains responsive under high load.
Also we can consider using Azure Event Hubs or Azure Event Grid as alternative delivery channels. These services are designed for high-throughput event streaming and can buffer notifications, reducing the load on our application.
This demo shows - on creation of an event in outlook calendar the CalendarCache is updated through the webhook Cron job was triggered manually through api - http://localhost:3000/api/calendar-cache/cron?apiKey=
https://www.loom.com/share/468bf851a93d49849b2dab27fe751efd?sid=458f9244-e4fe-4632-897d-b93835535ff6
The second demo shows the effect of caching on public team event page-
https://www.loom.com/share/567c3d5af03e478e97a44299e9bcc8da?sid=9254a7e4-a28b-4a49-b17e-2890489fcf84
MICROSOFT_WEBHOOK_TOKEN
- This token is sent with subscription requests through /subscriptions Graph API.
The notifications received by webhook are verified with this tokencalendar-cache
feature flag for the team.
Create a team event with hosts having their outlook calendars connectedcalendar-cache
On visiting the team event public page with &cal.cahce=true
, latest available slots are displayed with low latencyAdded caching and webhook support for Outlook (Office365) calendar availability to improve performance and enable real-time updates.
Vijay
@vijayraghav-io
Cal.com, Inc.
@cal