mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-05 18:26:40 +00:00
@@ -148,7 +148,7 @@ export async function cleanUpOldLogs(orgId: string, retentionDays: number) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function logRequestAudit(
|
export async function logRequestAudit(
|
||||||
data: {
|
data: {
|
||||||
action: boolean;
|
action: boolean;
|
||||||
reason: number;
|
reason: number;
|
||||||
@@ -174,14 +174,13 @@ export function logRequestAudit(
|
|||||||
}
|
}
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
// Quick synchronous check - if org has 0 retention, skip immediately
|
// Check retention before buffering any logs
|
||||||
if (data.orgId) {
|
if (data.orgId) {
|
||||||
const cached = cache.get<number>(`org_${data.orgId}_retentionDays`);
|
const retentionDays = await getRetentionDays(data.orgId);
|
||||||
if (cached === 0) {
|
if (retentionDays === 0) {
|
||||||
// do not log
|
// do not log
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// If not cached or > 0, we'll log it (async retention check happens in background)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let actorType: string | undefined;
|
let actorType: string | undefined;
|
||||||
@@ -261,16 +260,6 @@ export function logRequestAudit(
|
|||||||
} else {
|
} else {
|
||||||
scheduleFlush();
|
scheduleFlush();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async retention check in background (don't await)
|
|
||||||
if (
|
|
||||||
data.orgId &&
|
|
||||||
cache.get<number>(`org_${data.orgId}_retentionDays`) === undefined
|
|
||||||
) {
|
|
||||||
getRetentionDays(data.orgId).catch((err) =>
|
|
||||||
logger.error("Error checking retention days:", err)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
logger.error(error);
|
logger.error(error);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user