Minor fix for audit log system - after the switch to use an async queue for handling of audit log storage, context was lost - in multi-tenant environments need to carry the tenant ID into the queue job so that context can be applied.
This commit is contained in:
parent
c3806c0605
commit
bba6f6941c
2 changed files with 24 additions and 20 deletions
|
@ -8,7 +8,7 @@ import {
|
|||
HostInfo,
|
||||
} from "@budibase/types"
|
||||
import { EventProcessor } from "./types"
|
||||
import { getAppId } from "../../context"
|
||||
import { getAppId, doInTenant } from "../../context"
|
||||
import BullQueue from "bull"
|
||||
import { createQueue, JobQueue } from "../../queue"
|
||||
import { isAudited } from "../../utils"
|
||||
|
@ -26,6 +26,7 @@ export default class AuditLogsProcessor implements EventProcessor {
|
|||
JobQueue.AUDIT_LOG
|
||||
)
|
||||
return AuditLogsProcessor.auditLogQueue.process(async job => {
|
||||
return doInTenant(job.data.tenantId, async () => {
|
||||
let properties = job.data.properties
|
||||
if (properties.audited) {
|
||||
properties = {
|
||||
|
@ -50,6 +51,7 @@ export default class AuditLogsProcessor implements EventProcessor {
|
|||
hostInfo,
|
||||
})
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
async processEvent(
|
||||
|
@ -72,6 +74,7 @@ export default class AuditLogsProcessor implements EventProcessor {
|
|||
appId: getAppId(),
|
||||
hostInfo: identity.hostInfo,
|
||||
},
|
||||
tenantId: identity.tenantId!,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,4 +18,5 @@ export type AuditLogQueueEvent = {
|
|||
event: Event
|
||||
properties: any
|
||||
opts: AuditWriteOpts
|
||||
tenantId: string
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue