What does this PR do?
- Fixes #21050
- /claim #21050
Issue
The core issue is that fetching availability data for Outlook calendars currently involves querying the Microsoft Graph API every time someone views a public booking page that uses an Outlook calendar.
How it was fixed
Used the Google Calendar code as base to implement caching to the Microsoft Graph response and added a webhook to handle calendar change notifications and update the cache.
Also allowed office365_calendar
integration to be watched and unwatched on the calendar-cache
cronjob.
Next steps
We should refactor some duplicate code between googlecalendar.CalendarService
and office365calendar.CalendarService
.
Visual Demo (For contributors especially)
https://cap.link/e6g6jgd2t1nztd9
Mandatory Tasks (DO NOT REMOVE)
- I have self-reviewed the code (A decent size PR without self-review might be rejected).
- N/A
- I confirm automated tests are in place that prove my fix is effective or that my feature works.
How should this be tested?
- Are there environment variables that should be set?
OUTLOOK_WEBHOOK_TOKEN
: Token to verify incoming webhooks from Microsoft Outlook (Required)
OUTLOOK_WEBHOOK_URL
: Optional URL to override for tunelling webhooks. Defaults to NEXT_PUBLIC_WEBAPP_URL.
- What are the minimal test data to have?
- Setup two or more outlook calendars, create a team on cal.com and enable the
calendar-cache
feature flag for your team.
- What is expected (happy path) to have (input and output)?
- If all the above is meet, then:
- Go to the public page of one of your events, this should create an entry on
SelectedCalendar
table
- Run the
calendar-cache
cronjob manually or wait for it to run automatically
- The cronjob will subscribe to change notifications
- Add, update or delete an event in one of your calendars
- The webhook should be called and an entry should be added to
CalendarCache
table
- Any other important info that could help to test that PR
- Microsoft Graph requires the webhook callback url to be
https
Summary by mrge
Added support for caching Outlook calendar availability and handling Microsoft Graph webhooks to keep cache updated.
- New Features
- Added webhook endpoint for Outlook calendar event changes.
- Cached Outlook calendar availability to reduce API calls.
- Updated database schema to store Outlook subscription info.
- Extended calendar-cache logic to support Outlook calendars.