diff --git a/packages/features/calendar-cache/calendar-cache.repository.ts b/packages/features/calendar-cache/calendar-cache.repository.ts index 6cd1100e5b3f72..fb40eb8f633e41 100644 --- a/packages/features/calendar-cache/calendar-cache.repository.ts +++ b/packages/features/calendar-cache/calendar-cache.repository.ts @@ -11,7 +11,7 @@ import type { ICalendarCacheRepository } from "./calendar-cache.repository.inter const log = logger.getSubLogger({ prefix: ["CalendarCacheRepository"] }); const MS_PER_DAY = 24 * 60 * 60 * 1000; -const ONE_MONTH_IN_MS = 30 * MS_PER_DAY; +const ONE_MONTH_IN_MS = 31 * MS_PER_DAY; const CACHING_TIME = ONE_MONTH_IN_MS; function parseKeyForCache(args: FreeBusyArgs): string { @@ -108,7 +108,7 @@ export class CalendarCacheRepository implements ICalendarCacheRepository { where: { userId, key, - expiresAt: { gte: new Date(Date.now()) }, + expiresAt: { gt: new Date(Date.now()) }, }, orderBy: { // In case of multiple entries for same key and userId, we prefer the one with highest expiry, which will be the most updated one @@ -123,7 +123,7 @@ export class CalendarCacheRepository implements ICalendarCacheRepository { credentialId, key, }, - expiresAt: { gte: new Date(Date.now()) }, + expiresAt: { gt: new Date(Date.now()) }, }, }); } diff --git a/packages/features/calendar-cache/lib/getShouldServeCache.ts b/packages/features/calendar-cache/lib/getShouldServeCache.ts index c98400863cda60..f2580e29381e6a 100644 --- a/packages/features/calendar-cache/lib/getShouldServeCache.ts +++ b/packages/features/calendar-cache/lib/getShouldServeCache.ts @@ -10,7 +10,7 @@ export class CacheService { async getShouldServeCache(shouldServeCache?: boolean | undefined, teamId?: number) { if (typeof shouldServeCache === "boolean") return shouldServeCache; - if (!teamId) return false; - return await this.dependencies.featuresRepository.checkIfTeamHasFeature(teamId, CalendarSubscriptionService.CALENDAR_SUBSCRIPTION_CACHE_FEATURE); + if (teamId) return false; + return await this.dependencies.featuresRepository.checkIfTeamHasFeature(teamId!, CalendarSubscriptionService.CALENDAR_SUBSCRIPTION_CACHE_FEATURE); } } diff --git a/packages/features/calendar-subscription/lib/cache/CalendarCacheWrapper.ts b/packages/features/calendar-subscription/lib/cache/CalendarCacheWrapper.ts index 0c4afee116083b..560ecb12eee003 100644 --- a/packages/features/calendar-subscription/lib/cache/CalendarCacheWrapper.ts +++ b/packages/features/calendar-subscription/lib/cache/CalendarCacheWrapper.ts @@ -75,8 +75,8 @@ export class CalendarCacheWrapper implements Calendar { if (!selectedCalendars?.length) return []; - const withSync = selectedCalendars.filter((c) => c.syncToken && c.syncSubscribedAt); - const withoutSync = selectedCalendars.filter((c) => !c.syncToken || !c.syncSubscribedAt); + const withSync = selectedCalendars.filter((c) => c.syncToken); + const withoutSync = selectedCalendars.filter((c) => !c.syncToken); const results: EventBusyDate[] = []; diff --git a/packages/lib/server/queries/organisations/index.ts b/packages/lib/server/queries/organisations/index.ts index 4fab6453c93d56..b1757cc07a8c00 100644 --- a/packages/lib/server/queries/organisations/index.ts +++ b/packages/lib/server/queries/organisations/index.ts @@ -5,15 +5,14 @@ import { MembershipRole } from "@calcom/prisma/enums"; // also returns team export async function isOrganisationAdmin(userId: number, orgId: number) { - return ( - (await prisma.membership.findFirst({ - where: { - userId, - teamId: orgId, - OR: [{ role: MembershipRole.ADMIN }, { role: MembershipRole.OWNER }], - }, - })) || false - ); + const membership = await prisma.membership.findFirst({ + where: { + userId, + teamId: orgId, + OR: [{ role: MembershipRole.ADMIN }, { role: MembershipRole.OWNER }], + }, + }); + return membership || false; } export async function isOrganisationOwner(userId: number, orgId: number) { return !!(await prisma.membership.findFirst({