Wire prior archive cutoff through API

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-17 16:52:20 +03:30
co-authored by Cursor
parent 02841a5b8c
commit 79ba146118
11 changed files with 74 additions and 34 deletions
+9 -3
View File
@@ -658,7 +658,9 @@ export class AuthService {
const membership = await this.prisma.membership.findFirst({
where: { userId: user.id, organizationId, isActive: true },
include: {
organization: { select: { name: true, enabledModules: true } },
organization: {
select: { name: true, enabledModules: true, priorArchiveEnabledAt: true },
},
},
});
const role = membership?.role ?? user.role;
@@ -685,13 +687,17 @@ export class AuthService {
membership: {
priorArchiveEnabled?: boolean;
priorArchiveLens?: string;
organization?: { enabledModules?: string[] };
organization?: { enabledModules?: string[]; priorArchiveEnabledAt?: Date | null };
} | null,
): AuthUserDto['priorArchive'] {
if (!membership?.priorArchiveEnabled) return undefined;
const modules = this.billing.normalizeModules(membership.organization?.enabledModules);
if (!modules.includes('prior_data_archive')) return undefined;
return { lens: membership.priorArchiveLens === 'archive' ? 'archive' : 'current' };
const orgCutoff = membership.organization?.priorArchiveEnabledAt ?? null;
return {
lens: membership.priorArchiveLens === 'archive' ? 'archive' : 'current',
cutoffAt: orgCutoff ? orgCutoff.toISOString() : null,
};
}
private async throttleChallenges(
+4 -1
View File
@@ -107,7 +107,10 @@ export class JwtStrategy extends PassportStrategy(Strategy) {
visibleUserIds,
scopes,
priorLens: priorGranted ? priorLens : 'off',
priorCutoff: priorGranted ? membership.organization.priorArchiveEnabledAt : null,
priorCutoff:
priorGranted && membership.organization.priorArchiveEnabledAt
? membership.organization.priorArchiveEnabledAt
: null,
};
}