UBERF-6725 Use workspace url instead of id in guest link (#5469)

Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
Alexander Onnikov 2024-04-25 22:13:58 +07:00 committed by GitHub
parent 1e71183c78
commit 96d4b0ec23
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,7 +21,7 @@ import {
TxCreateDoc,
TxOperations,
TxProcessor,
WorkspaceId,
WorkspaceIdWithUrl,
concatLink,
generateId
} from '@hcengineering/core'
@ -54,13 +54,13 @@ export async function OnPublicLinkCreate (tx: Tx, control: TriggerControl): Prom
return res
}
export function getPublicLinkUrl (workspace: WorkspaceId): string {
export function getPublicLinkUrl (workspace: WorkspaceIdWithUrl): string {
const front = getMetadata(serverCore.metadata.FrontUrl) ?? ''
const path = `${guestId}/${workspace.name}`
const path = `${guestId}/${workspace.workspaceUrl}`
return concatLink(front, path)
}
function generateUrl (linkId: Ref<PublicLink>, workspace: WorkspaceId): string {
function generateUrl (linkId: Ref<PublicLink>, workspace: WorkspaceIdWithUrl): string {
const token = generateToken(guestAccountEmail, workspace, { linkId, guest: 'true' })
return `${getPublicLinkUrl(workspace)}?token=${token}`
}
@ -68,7 +68,7 @@ function generateUrl (linkId: Ref<PublicLink>, workspace: WorkspaceId): string {
export async function getPublicLink (
doc: Doc,
client: TxOperations,
workspace: WorkspaceId,
workspace: WorkspaceIdWithUrl,
revokable: boolean = true
): Promise<string> {
const current = await client.findOne(guest.class.PublicLink, { attachedTo: doc._id })