Merge pull request #9844 from Budibase/fix/audit-log-muli-tenant

Audit log multi-tenancy fix
This commit is contained in:
Michael Drury 2023-03-01 17:27:55 +00:00 committed by GitHub
commit a7d5f0fa7e
2 changed files with 24 additions and 20 deletions

View File

@ -8,7 +8,7 @@ import {
HostInfo, HostInfo,
} from "@budibase/types" } from "@budibase/types"
import { EventProcessor } from "./types" import { EventProcessor } from "./types"
import { getAppId } from "../../context" import { getAppId, doInTenant } from "../../context"
import BullQueue from "bull" import BullQueue from "bull"
import { createQueue, JobQueue } from "../../queue" import { createQueue, JobQueue } from "../../queue"
import { isAudited } from "../../utils" import { isAudited } from "../../utils"
@ -26,6 +26,7 @@ export default class AuditLogsProcessor implements EventProcessor {
JobQueue.AUDIT_LOG JobQueue.AUDIT_LOG
) )
return AuditLogsProcessor.auditLogQueue.process(async job => { return AuditLogsProcessor.auditLogQueue.process(async job => {
return doInTenant(job.data.tenantId, async () => {
let properties = job.data.properties let properties = job.data.properties
if (properties.audited) { if (properties.audited) {
properties = { properties = {
@ -50,6 +51,7 @@ export default class AuditLogsProcessor implements EventProcessor {
hostInfo, hostInfo,
}) })
}) })
})
} }
async processEvent( async processEvent(
@ -72,6 +74,7 @@ export default class AuditLogsProcessor implements EventProcessor {
appId: getAppId(), appId: getAppId(),
hostInfo: identity.hostInfo, hostInfo: identity.hostInfo,
}, },
tenantId: identity.tenantId!,
}) })
} }
} }

View File

@ -18,4 +18,5 @@ export type AuditLogQueueEvent = {
event: Event event: Event
properties: any properties: any
opts: AuditWriteOpts opts: AuditWriteOpts
tenantId: string
} }