feat: implement Office365 calendar cache and subscription services#22967
feat: implement Office365 calendar cache and subscription services#22967zomars wants to merge 6 commits intodevin/1753300938-calendar-cache-sql-systemfrom
Conversation
- Add Office365-specific fields to CalendarSubscription model - Create Office365CalendarSubscriptionService following Google patterns - Add Office365CalendarWebhookService for webhook processing - Update CalendarCacheSqlService to handle Office365 events - Add webhook API endpoint for Office365 calendar notifications - Update repository interfaces to support both Google and Office365 - Add required environment variables to turbo.json - Fix TypeScript warnings and improve type safety Co-Authored-By: zomars@cal.com <zomars@me.com>
- Fix subscription parameter types in processGoogleWebhookEvents and processOffice365WebhookEvents - Add proper type annotations for selectedCalendar relation - Ensure compatibility with repository return types Co-Authored-By: zomars@cal.com <zomars@me.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing Touches🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
DevinAIm where is this file being used?
|
The is used through a dispatcher pattern in the main calendar subscription system: Usage Points:1. Main Dispatcher Service:
2. Dynamic Import Pattern: const { CalendarSubscriptionService } = await import(
"@calcom/app-store/office365calendar/lib/CalendarSubscriptionService"
);
const subscriptionService = new CalendarSubscriptionService(credentialWithTenantId);
return await subscriptionService.watchCalendar(calendarId);3. Integration Flow:
This follows the same pattern as Google Calendar's implementation, keeping provider-specific code isolated in their respective app-store directories while using a common interface. |
- Create CalendarSubscriptionServiceFactory with proper interface segregation - Extract ICalendarSubscriptionService interface for provider implementations - Remove provider-specific logic from main CalendarSubscriptionService - Standardize unwatchCalendar method signatures across providers - Improve separation of concerns following existing getCalendar patterns - Maintain backward compatibility with existing integrations Co-Authored-By: zomars@cal.com <zomars@me.com>
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎ |
…pattern - Create CalendarWebhookServiceFactory for dynamic service instantiation - Move Google Calendar webhook logic to GoogleCalendarWebhookService - Move Office365 Calendar webhook logic to Office365CalendarWebhookService - Remove provider-specific methods from CalendarCacheSqlService - Implement ICalendarWebhookService interface for consistency - Improve separation of concerns and maintainability Co-Authored-By: zomars@cal.com <zomars@me.com>
- Remove unused logger imports from webhook services - Fix non-null assertion in CalendarCacheSqlService - Improve type safety in CalendarWebhookServiceFactory - Update interface definitions to use proper types Co-Authored-By: zomars@cal.com <zomars@me.com>
- Update ICalendarWebhookService interface to use proper types - Replace any with CredentialPayload in Google and Office365 webhook services - Resolves remaining lint warnings for Codacy Static Code Analysis Co-Authored-By: zomars@cal.com <zomars@me.com>
| calendarId: string, | ||
| credential: CredentialForCalendarService | ||
| ): Promise<GoogleChannelProps | undefined> { | ||
| ): Promise<GoogleChannelProps | Office365SubscriptionProps | undefined> { |
There was a problem hiding this comment.
This is weird to support either type of props here
|
This PR is being marked as stale due to inactivity. |
|
Closing as work is continuing #23675 |
Refactor CalendarCacheSqlService provider logic using factory pattern
Summary
This PR refactors the
CalendarCacheSqlServiceto improve separation of concerns by extracting provider-specific webhook processing logic into dedicated services. The mainCalendarCacheSqlServicepreviously contained mixed Google Calendar and Office365 logic in a single class, making it difficult to maintain and extend.Key Changes:
CalendarWebhookServiceFactoryfor dynamic service instantiation based on credential typeGoogleCalendarWebhookServiceOffice365CalendarWebhookServiceICalendarWebhookServiceinterface for consistency across providersThe refactoring maintains all existing functionality while improving code organization and making it easier to add new calendar providers.
Review & Testing Checklist for Human
subject→summary,@odata.etag→etag, etc.)CalendarWebhookServiceFactory.createService()correctly instantiates the right service for bothgoogle_calendarandoffice365_calendarcredential typesfindByChannelId(Google) andfindByOffice365SubscriptionId(Office365) work correctly in the refactoredprocessWebhookEventsmethodparseCalendarEventsandparseOffice365Events) produce identical database records to the original implementationDiagram
%%{ init : { "theme" : "default" }}%% graph TB CalendarCacheSqlService["CalendarCacheSqlService.ts<br/>(Major Refactor)"]:::major-edit WebhookServiceFactory["CalendarWebhookServiceFactory.ts<br/>(New Factory)"]:::major-edit GoogleWebhookService["googlecalendar/lib/<br/>CalendarWebhookService.ts<br/>(New Service)"]:::major-edit Office365WebhookService["office365calendar/lib/<br/>CalendarWebhookService.ts<br/>(New Service)"]:::major-edit IWebhookService["ICalendarWebhookService<br/>(New Interface)"]:::major-edit SubscriptionRepo["CalendarSubscription<br/>Repository"]:::context EventRepo["CalendarEvent<br/>Repository"]:::context CalendarCacheSqlService -->|"delegates to"| WebhookServiceFactory WebhookServiceFactory -->|"creates Google service"| GoogleWebhookService WebhookServiceFactory -->|"creates Office365 service"| Office365WebhookService GoogleWebhookService -.->|"implements"| IWebhookService Office365WebhookService -.->|"implements"| IWebhookService GoogleWebhookService -->|"uses"| SubscriptionRepo GoogleWebhookService -->|"uses"| EventRepo Office365WebhookService -->|"uses"| SubscriptionRepo Office365WebhookService -->|"uses"| EventRepo subgraph Legend L1[Major Edit]:::major-edit L2[Minor Edit]:::minor-edit L3[Context/No Edit]:::context end classDef major-edit fill:#90EE90 classDef minor-edit fill:#87CEEB classDef context fill:#FFFFFFNotes
Session Details: