mirror of
https://github.com/hcengineering/platform.git
synced 2025-03-15 02:23:12 +00:00
fix: wrong workspace id passed to collaborator client (#7950)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
608759ad56
commit
3307cd74cc
@ -57,20 +57,21 @@ import { type PlatformClient, type ConnectOptions, WithMarkup } from './types'
|
||||
export async function connect (url: string, options: ConnectOptions): Promise<PlatformClient> {
|
||||
const config = await loadServerConfig(url)
|
||||
|
||||
const { endpoint, token } = await getWorkspaceToken(url, options, config)
|
||||
return await createClient(url, endpoint, token, config, options)
|
||||
const { endpoint, token, workspaceId } = await getWorkspaceToken(url, options, config)
|
||||
return await createClient(url, endpoint, workspaceId, token, config, options)
|
||||
}
|
||||
|
||||
async function createClient (
|
||||
url: string,
|
||||
endpoint: string,
|
||||
workspaceId: string,
|
||||
token: string,
|
||||
config: ServerConfig,
|
||||
options: ConnectOptions
|
||||
): Promise<PlatformClient> {
|
||||
addLocation(clientId, () => import(/* webpackChunkName: "client" */ '@hcengineering/client-resources'))
|
||||
|
||||
const { workspace, socketFactory, connectionTimeout } = options
|
||||
const { socketFactory, connectionTimeout } = options
|
||||
|
||||
const clientFactory = await getResource(client.function.GetClient)
|
||||
const connection = await clientFactory(token, endpoint, {
|
||||
@ -79,7 +80,7 @@ async function createClient (
|
||||
})
|
||||
const account = await connection.getAccount()
|
||||
|
||||
return new PlatformClientImpl(url, workspace, token, config, connection, account)
|
||||
return new PlatformClientImpl(url, workspaceId, token, config, connection, account)
|
||||
}
|
||||
|
||||
class PlatformClientImpl implements PlatformClient {
|
||||
@ -100,6 +101,10 @@ class PlatformClientImpl implements PlatformClient {
|
||||
|
||||
// Client
|
||||
|
||||
getAccount (): Account {
|
||||
return { ...this.account }
|
||||
}
|
||||
|
||||
getHierarchy (): Hierarchy {
|
||||
return this.client.getHierarchy()
|
||||
}
|
||||
@ -277,7 +282,7 @@ async function getWorkspaceToken (
|
||||
url: string,
|
||||
options: ConnectOptions,
|
||||
config?: ServerConfig
|
||||
): Promise<{ endpoint: string, token: string }> {
|
||||
): Promise<{ endpoint: string, token: string, workspaceId: string }> {
|
||||
config ??= await loadServerConfig(url)
|
||||
|
||||
let token: string
|
||||
@ -298,5 +303,5 @@ async function getWorkspaceToken (
|
||||
throw new Error('Workspace not found')
|
||||
}
|
||||
|
||||
return { endpoint: ws.endpoint, token: ws.token }
|
||||
return { endpoint: ws.endpoint, token: ws.token, workspaceId: ws.workspaceId }
|
||||
}
|
||||
|
@ -16,6 +16,7 @@
|
||||
import { type ClientSocketFactory } from '@hcengineering/client'
|
||||
import {
|
||||
CollaborativeDoc,
|
||||
type Account,
|
||||
type AttachedData,
|
||||
type AttachedDoc,
|
||||
type Class,
|
||||
@ -53,6 +54,8 @@ MarkupContent
|
||||
* @public
|
||||
* */
|
||||
export type PlatformClient = {
|
||||
getAccount: () => Account
|
||||
|
||||
getHierarchy: () => Hierarchy
|
||||
|
||||
getModel: () => ModelDb
|
||||
|
Loading…
Reference in New Issue
Block a user