feat: allows forcing/skipping calendar cache serving (#18224)
* feat: allows forcing/skipping calendar cache serving Signed-off-by: Omar López <[email protected]> * Update features.repository.ts * Added to HNB * type fixes * Update packages/prisma/migrations/20241216000000_add_calendar_cache_serve/migration.sql Co-authored-by: Keith Williams <[email protected]> * Update packages/prisma/zod-utils.ts Co-authored-by: Keith Williams <[email protected]> * Update selectedCalendar.ts --------- Signed-off-by: Omar López <[email protected]> Co-authored-by: Keith Williams <[email protected]>
This commit is contained in:
1 parent
a0f986f949
commit
2eb385af48
24 files changed
+217
-125
No files matched your search
@@ -4,6 +4,7 @@
|
||||
**/
|
||||
export type AppFlags = {
|
||||
"calendar-cache": boolean;
|
||||
"calendar-cache-serve": boolean;
|
||||
emails: boolean;
|
||||
insights: boolean;
|
||||
teams: boolean;
|
||||
|
||||
@@ -3,4 +3,5 @@ import type { AppFlags } from "./config";
|
||||
export interface IFeaturesRepository {
|
||||
checkIfFeatureIsEnabledGlobally(slug: keyof AppFlags): Promise<boolean>;
|
||||
checkIfUserHasFeature(userId: number, slug: string): Promise<boolean>;
|
||||
checkIfTeamHasFeature(teamId: number, slug: keyof AppFlags): Promise<boolean>;
|
||||
}
|
||||
@@ -4,6 +4,9 @@ export class MockFeaturesRepository implements IFeaturesRepository {
|
||||
async checkIfUserHasFeature(userId: number, slug: string) {
|
||||
return slug === "mock-feature";
|
||||
}
|
||||
async checkIfTeamHasFeature(team: number, slug: string) {
|
||||
return slug === "mock-feature";
|
||||
}
|
||||
async checkIfFeatureIsEnabledGlobally() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -65,4 +65,15 @@ export class FeaturesRepository implements IFeaturesRepository {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
async checkIfTeamHasFeature(teamId: number, featureId: keyof AppFlags) {
|
||||
try {
|
||||
const teamFeature = await db.teamFeatures.findUnique({
|
||||
where: { teamId_featureId: { teamId, featureId } },
|
||||
});
|
||||
return !!teamFeature;
|
||||
} catch (err) {
|
||||
captureException(err);
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ const initialData: AppFlags = {
|
||||
organizations: false,
|
||||
teams: false,
|
||||
"calendar-cache": false,
|
||||
"calendar-cache-serve": false,
|
||||
emails: false,
|
||||
insights: false,
|
||||
webhooks: false,
|
||||
|
||||
Reference in new issue
Block a user