packages/features/calendar-subscription/README.md
The Calendar Cache and Sync feature provides efficient calendar synchronization with intelligent caching to reduce API calls and ensure real-time updates across your Cal.com instance.
This feature introduces two complementary capabilities:
Key Benefits:
Motivation: By subscribing to calendars via webhooks and implementing intelligent caching, you gain a smarter, faster, and more resource-friendly way to keep your data in sync. This eliminates the need for constant polling and reduces the load on external calendar APIs while ensuring data consistency.
This feature is controlled by three feature flags that can be enabled independently:
Enables calendar cache recording and usage through calendars. This flag should be managed individually by teams.
INSERT INTO "Feature" ("slug", "enabled", "description", "type", "stale", "lastUsedAt", "createdAt", "updatedAt", "updatedBy")
VALUES ('calendar-subscription-cache', false, 'Allow calendar cache to be recorded and used through calendars.', 'OPERATIONAL', false, NULL, NOW(), NOW(), NULL)
ON CONFLICT (slug) DO NOTHING;
Enables calendar sync globally for all users regardless of team or organization.
INSERT INTO "Feature" ("slug", "enabled", "description", "type", "stale", "lastUsedAt", "createdAt", "updatedAt", "updatedBy")
VALUES ('calendar-subscription-sync', false, 'Enable calendar sync for all calendars globally.', 'OPERATIONAL', false, NULL, NOW(), NOW(), NULL)
ON CONFLICT (slug) DO NOTHING;
To enable calendar cache features for specific users, add entries to the UserFeatures table:
-- Enable calendar-subscription-cache for user ID 123
INSERT INTO "UserFeatures" ("userId", "featureId", "assignedAt", "assignedBy", "updatedAt")
VALUES (123, 'calendar-subscription-cache', NOW(), 'admin', NOW())
ON CONFLICT ("userId", "featureId") DO NOTHING;
-- Enable calendar-subscription-sync for user ID 123
INSERT INTO "UserFeatures" ("userId", "featureId", "assignedAt", "assignedBy", "updatedAt")
VALUES (123, 'calendar-subscription-sync', NOW(), 'admin', NOW())
ON CONFLICT ("userId", "featureId") DO NOTHING;
To enable calendar cache features for specific teams, add entries to the TeamFeatures table:
-- Enable calendar-subscription-cache for team ID 456
INSERT INTO "TeamFeatures" ("teamId", "featureId", "assignedAt", "assignedBy", "updatedAt")
VALUES (456, 'calendar-subscription-cache', NOW(), 'admin', NOW())
ON CONFLICT ("teamId", "featureId") DO NOTHING;
-- Enable calendar-subscription-sync for team ID 456
INSERT INTO "TeamFeatures" ("teamId", "featureId", "assignedAt", "assignedBy", "updatedAt")
VALUES (456, 'calendar-subscription-sync', NOW(), 'admin', NOW())
ON CONFLICT ("teamId", "featureId") DO NOTHING;
The calendar cache and sync system consists of several key components:
channelId: Webhook channel identifierchannelResourceId: Resource ID for webhook subscriptionschannelResourceUri: URI for webhook notificationschannelKind: Type of webhook channelchannelExpiration: Webhook subscription expiration timesyncToken: Token for incremental syncsyncedAt: Last successful sync timestampsyncErrorAt: Last sync error timestampsyncErrorCount: Number of consecutive sync errorssyncSubscribedAt: Webhook subscription timestampFor detailed technical implementation, see:
packages/prisma/migrations/