Making sure tenant ID is always available to the builder websocket.
This commit is contained in:
parent
eebd9d2d7c
commit
d5a03bf5e3
|
@ -203,15 +203,6 @@ export function getTenantId(): string {
|
||||||
return tenantId
|
return tenantId
|
||||||
}
|
}
|
||||||
|
|
||||||
export function hasTenantId(): boolean {
|
|
||||||
if (!isMultiTenant()) {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
const context = Context.get()
|
|
||||||
const tenantId = context?.tenantId
|
|
||||||
return tenantId != null
|
|
||||||
}
|
|
||||||
|
|
||||||
export function getAutomationId(): string | undefined {
|
export function getAutomationId(): string | undefined {
|
||||||
const context = Context.get()
|
const context = Context.get()
|
||||||
return context?.automationId
|
return context?.automationId
|
||||||
|
|
|
@ -15,7 +15,6 @@ import { gridSocket } from "./index"
|
||||||
import { clearLock, updateLock } from "../utilities/redis"
|
import { clearLock, updateLock } from "../utilities/redis"
|
||||||
import { Socket } from "socket.io"
|
import { Socket } from "socket.io"
|
||||||
import { BuilderSocketEvent } from "@budibase/shared-core"
|
import { BuilderSocketEvent } from "@budibase/shared-core"
|
||||||
import { hasTenantId } from "@budibase/backend-core/src/context"
|
|
||||||
|
|
||||||
export default class BuilderSocket extends BaseSocket {
|
export default class BuilderSocket extends BaseSocket {
|
||||||
constructor(app: Koa, server: http.Server) {
|
constructor(app: Koa, server: http.Server) {
|
||||||
|
@ -36,8 +35,11 @@ export default class BuilderSocket extends BaseSocket {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
if (context.hasTenantId()) {
|
const tenantId = context.getTenantIDFromAppID(appId)
|
||||||
await events.user.dataCollaboration(Object.keys(userIdMap).length)
|
if (tenantId) {
|
||||||
|
await context.doInTenant(tenantId, async () => {
|
||||||
|
await events.user.dataCollaboration(Object.keys(userIdMap).length)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reply with all current sessions
|
// Reply with all current sessions
|
||||||
|
|
Loading…
Reference in New Issue