ezqms-1057: fix images in branded workspaces (#5979)

This commit is contained in:
Alexey Zinoviev 2024-07-02 15:12:39 +04:00 committed by GitHub
parent 3dd78b5856
commit cd5db6a9c3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 17 additions and 26 deletions

View File

@ -56,9 +56,9 @@ export function start (
const pipelineFactory = createServerPipeline(metrics, dbUrl, { ...opt, externalStorage })
const sessionFactory = (token: Token, pipeline: Pipeline): Session => {
if (token.extra?.mode === 'backup') {
return new BackupClientSession(token, pipeline, opt.brandingMap)
return new BackupClientSession(token, pipeline)
}
return new ClientSession(token, pipeline, opt.brandingMap)
return new ClientSession(token, pipeline)
}
const onClose = startJsonRpc(getMetricsContext(), {

View File

@ -24,6 +24,7 @@ import core, {
TxProcessor,
cutObjectArray,
toFindResult,
type Branding,
type Account,
type AttachedDoc,
type Class,
@ -87,6 +88,7 @@ export class TServerStorage implements ServerStorage {
triggerData = new Map<Metadata<any>, any>()
liveQuery: LQ
branding: Branding | null
domainInfo = new Map<
Domain,
@ -119,6 +121,7 @@ export class TServerStorage implements ServerStorage {
this.liveQuery = new LQ(this.newCastClient(hierarchy, modelDb, metrics))
this.hierarchy = hierarchy
this.fulltext = indexFactory(this)
this.branding = options.branding
this.setModel(model)
}

View File

@ -69,7 +69,7 @@ export interface ServerStorage extends LowLevelStorage {
close: () => Promise<void>
loadModel: (last: Timestamp, hash?: string) => Promise<Tx[] | LoadModelResponse>
workspaceId: WorkspaceIdWithUrl
branding?: string
branding: Branding | null
storageAdapter: StorageAdapter
}

View File

@ -1,4 +1,4 @@
import { type BrandingMap, Doc, DocInfo, Domain, Ref, StorageIterator } from '@hcengineering/core'
import { Doc, DocInfo, Domain, Ref, StorageIterator } from '@hcengineering/core'
import { Pipeline, estimateDocSize } from '@hcengineering/server-core'
import { Token } from '@hcengineering/server-token'
import { ClientSession, Session, type ClientSessionCtx } from '@hcengineering/server-ws'
@ -30,10 +30,9 @@ export interface BackupSession extends Session {
export class BackupClientSession extends ClientSession implements BackupSession {
constructor (
protected readonly token: Token,
protected readonly _pipeline: Pipeline,
protected readonly brandingMap: BrandingMap
protected readonly _pipeline: Pipeline
) {
super(token, _pipeline, brandingMap)
super(token, _pipeline)
}
idIndex = 0

View File

@ -82,7 +82,7 @@ describe('server', () => {
return { docs: [] }
}
}),
sessionFactory: (token, pipeline) => new ClientSession(token, pipeline, {}),
sessionFactory: (token, pipeline) => new ClientSession(token, pipeline),
port: 3335,
productId: '',
brandingMap: {},
@ -183,7 +183,7 @@ describe('server', () => {
return { docs: [] }
}
}),
sessionFactory: (token, pipeline) => new ClientSession(token, pipeline, {}),
sessionFactory: (token, pipeline) => new ClientSession(token, pipeline),
port: 3336,
productId: '',
brandingMap: {},

View File

@ -32,9 +32,7 @@ import core, {
type Tx,
type TxApplyIf,
type TxApplyResult,
type TxCUD,
type Branding,
type BrandingMap
type TxCUD
} from '@hcengineering/core'
import { SessionContextImpl, createBroadcastEvent, type Pipeline } from '@hcengineering/server-core'
import { type Token } from '@hcengineering/server-token'
@ -58,8 +56,7 @@ export class ClientSession implements Session {
constructor (
protected readonly token: Token,
protected readonly _pipeline: Pipeline,
protected readonly brandingMap: BrandingMap
protected readonly _pipeline: Pipeline
) {}
getUser (): string {
@ -78,14 +75,6 @@ export class ClientSession implements Session {
return this._pipeline
}
getBranding (brandingKey?: string): Branding | null {
if (brandingKey === undefined) {
return null
}
return this.brandingMap[brandingKey] ?? null
}
async ping (ctx: ClientSessionCtx): Promise<void> {
// console.log('ping')
this.lastRequest = Date.now()
@ -127,7 +116,7 @@ export class ClientSession implements Session {
this.token.extra?.admin === 'true',
[],
this._pipeline.storage.workspaceId,
this.getBranding(this._pipeline.storage.branding)
this._pipeline.storage.branding
)
await this._pipeline.tx(context, createTx)
const acc = TxProcessor.createDoc2Doc(createTx)
@ -157,7 +146,7 @@ export class ClientSession implements Session {
this.token.extra?.admin === 'true',
[],
this._pipeline.storage.workspaceId,
this.getBranding(this._pipeline.storage.branding)
this._pipeline.storage.branding
)
return await this._pipeline.findAll(context, _class, query, options)
}
@ -180,7 +169,7 @@ export class ClientSession implements Session {
this.token.extra?.admin === 'true',
[],
this._pipeline.storage.workspaceId,
this.getBranding(this._pipeline.storage.branding)
this._pipeline.storage.branding
)
await ctx.sendResponse(await this._pipeline.searchFulltext(context, query, options))
}
@ -196,7 +185,7 @@ export class ClientSession implements Session {
this.token.extra?.admin === 'true',
[],
this._pipeline.storage.workspaceId,
this.getBranding(this._pipeline.storage.branding)
this._pipeline.storage.branding
)
const result = await this._pipeline.tx(context, tx)