mirror of
https://github.com/hcengineering/platform.git
synced 2025-04-30 12:15:51 +00:00
fix: use workspace uuid in image and blob links (#8019)
Signed-off-by: Alexander Onnikov <Alexander.Onnikov@xored.com>
This commit is contained in:
parent
1205a20286
commit
f0f63391ff
@ -99,12 +99,9 @@ function getFilesUrl (): string {
|
||||
return filesUrl.includes('://') ? filesUrl : concatLink(frontUrl, filesUrl)
|
||||
}
|
||||
|
||||
export function getCurrentWorkspaceId (): WorkspaceDataId {
|
||||
return (
|
||||
getMetadata(plugin.metadata.WorkspaceDataId) ??
|
||||
(getMetadata(plugin.metadata.WorkspaceUuid) as unknown as WorkspaceDataId) ??
|
||||
('' as WorkspaceDataId)
|
||||
)
|
||||
export function getCurrentWorkspaceUuid (): WorkspaceDataId {
|
||||
const workspaceUuid = getMetadata(plugin.metadata.WorkspaceUuid) ?? ''
|
||||
return workspaceUuid as WorkspaceDataId
|
||||
}
|
||||
|
||||
/**
|
||||
@ -120,7 +117,7 @@ export function generateFileId (): string {
|
||||
export function getUploadUrl (): string {
|
||||
const template = getMetadata(plugin.metadata.UploadURL) ?? defaultUploadUrl
|
||||
|
||||
return template.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId()))
|
||||
return template.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid()))
|
||||
}
|
||||
|
||||
function getUploadConfig (): UploadConfig {
|
||||
@ -142,7 +139,7 @@ function getFileUploadMethod (blob: Blob): { method: FileUploadMethod, url: stri
|
||||
* @public
|
||||
*/
|
||||
export function getFileUploadParams (blobId: string, blob: Blob): FileUploadParams {
|
||||
const workspaceId = encodeURIComponent(getCurrentWorkspaceId())
|
||||
const workspaceId = encodeURIComponent(getCurrentWorkspaceUuid())
|
||||
const fileId = encodeURIComponent(blobId)
|
||||
|
||||
const { method, url: urlTemplate } = getFileUploadMethod(blob)
|
||||
@ -170,7 +167,7 @@ export function getFileUrl (file: string, filename?: string): string {
|
||||
const template = getFilesUrl()
|
||||
return template
|
||||
.replaceAll(':filename', encodeURIComponent(filename ?? file))
|
||||
.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId()))
|
||||
.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid()))
|
||||
.replaceAll(':blobId', encodeURIComponent(file))
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ import type { Blob, Ref } from '@hcengineering/core'
|
||||
import { concatLink } from '@hcengineering/core'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
|
||||
import { getFileUrl, getCurrentWorkspaceId } from './file'
|
||||
import { getFileUrl, getCurrentWorkspaceUuid } from './file'
|
||||
import presentation from './plugin'
|
||||
|
||||
export interface PreviewConfig {
|
||||
@ -16,7 +16,7 @@ export interface VideoMeta {
|
||||
hls: string
|
||||
}
|
||||
|
||||
const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceId()}?file=:blobId&size=:size`
|
||||
const defaultImagePreview = (): string => `/files/${getCurrentWorkspaceUuid()}?file=:blobId&size=:size`
|
||||
|
||||
/**
|
||||
*
|
||||
@ -93,7 +93,7 @@ function blobToSrcSet (
|
||||
return ''
|
||||
}
|
||||
|
||||
let url = cfg.image.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId()))
|
||||
let url = cfg.image.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid()))
|
||||
const downloadUrl = getFileUrl(blob)
|
||||
|
||||
const frontUrl = getMetadata(presentation.metadata.FrontUrl) ?? window.location.origin
|
||||
@ -139,7 +139,7 @@ export async function getVideoMeta (file: string, filename?: string): Promise<Vi
|
||||
const cfg = getPreviewConfig()
|
||||
|
||||
let url = cfg.video
|
||||
.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceId()))
|
||||
.replaceAll(':workspace', encodeURIComponent(getCurrentWorkspaceUuid()))
|
||||
.replaceAll(':blobId', encodeURIComponent(file))
|
||||
|
||||
if (url === '') {
|
||||
|
@ -253,9 +253,7 @@ function clearMetadata (ws: string): void {
|
||||
delete tokens[loc.path[1]]
|
||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||
}
|
||||
const currentWorkspace =
|
||||
getMetadata(presentation.metadata.WorkspaceDataId) ??
|
||||
(getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId)
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
||||
if (currentWorkspace !== undefined) {
|
||||
setPresentationCookie('', currentWorkspace)
|
||||
}
|
||||
|
@ -16,13 +16,12 @@
|
||||
import { AccountRole, getCurrentAccount, hasAccountRole } from '@hcengineering/core'
|
||||
import { getMetadata } from '@hcengineering/platform'
|
||||
import presentation from '@hcengineering/presentation'
|
||||
import { Breadcrumb, Button, Expandable, Header, Label, Link, Loading } from '@hcengineering/ui'
|
||||
import { Breadcrumb, Button, Expandable, Header, Label, Loading } from '@hcengineering/ui'
|
||||
import Scroller from '@hcengineering/ui/src/components/Scroller.svelte'
|
||||
import view from '@hcengineering/view'
|
||||
import { onMount } from 'svelte'
|
||||
import setting from '../plugin'
|
||||
import { BackupInfo, BackupSnapshot } from '../types'
|
||||
import Expand from '@hcengineering/ui/src/components/icons/Expand.svelte'
|
||||
|
||||
let loading = true
|
||||
|
||||
|
@ -445,9 +445,7 @@ export function clearMetadata (ws: string): void {
|
||||
delete tokens[loc.path[1]]
|
||||
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
|
||||
}
|
||||
const currentWorkspace =
|
||||
getMetadata(presentation.metadata.WorkspaceDataId) ??
|
||||
(getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId)
|
||||
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceUuid) as unknown as WorkspaceDataId
|
||||
if (currentWorkspace !== undefined) {
|
||||
setPresentationCookie('', currentWorkspace)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user