Skip to content

Commit

Permalink
fix: URI encode datalake blob id and more workspace fixes (#6449)
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Onnikov <[email protected]>
  • Loading branch information
aonnikov authored Aug 30, 2024
1 parent 202adb5 commit 1502899
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion packages/presentation/src/collaborator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import presentation from './plugin'

/** @public */
export function getCollaboratorClient (): CollaboratorClient {
const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.Workspace) ?? '')
const workspaceId = getWorkspaceId(getMetadata(presentation.metadata.WorkspaceId) ?? '')
const token = getMetadata(presentation.metadata.Token) ?? ''
const collaboratorURL = getMetadata(presentation.metadata.CollaboratorUrl) ?? ''

Expand Down
2 changes: 1 addition & 1 deletion plugins/guest-resources/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ function clearMetadata (ws: string): void {
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
const currentWorkspace = getMetadata(presentation.metadata.Workspace)
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId)
if (currentWorkspace !== undefined) {
setPresentationCookie('', currentWorkspace)
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/text-editor-resources/src/provider/indexeddb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export class IndexeddbProvider extends IndexeddbPersistence implements Provider
readonly awareness: Awareness | null = null

constructor (documentId: string, doc: YDoc) {
const workspaceId: string = getMetadata(presentation.metadata.Workspace) ?? ''
const workspaceId: string = getMetadata(presentation.metadata.WorkspaceId) ?? ''

const name = `${workspaceId}/${documentId}`

Expand Down
2 changes: 1 addition & 1 deletion plugins/text-editor-resources/src/provider/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { IndexeddbProvider } from './indexeddb'
import { type Provider } from './types'

export function formatCollaborativeDocumentId (collaborativeDoc: CollaborativeDoc): DocumentId {
const workspace = getMetadata(presentation.metadata.Workspace) ?? ''
const workspace = getMetadata(presentation.metadata.WorkspaceId) ?? ''
return formatDocumentId(workspace, collaborativeDoc)
}

Expand Down
2 changes: 1 addition & 1 deletion plugins/workbench-resources/src/connect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ function clearMetadata (ws: string): void {
delete tokens[loc.path[1]]
setMetadataLocalStorage(login.metadata.LoginTokens, tokens)
}
const currentWorkspace = getMetadata(presentation.metadata.Workspace)
const currentWorkspace = getMetadata(presentation.metadata.WorkspaceId)
if (currentWorkspace !== undefined) {
setPresentationCookie('', currentWorkspace)
}
Expand Down
2 changes: 1 addition & 1 deletion server/collaborator/src/extensions/authentication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export class AuthenticationExtension implements Extension {
const workspaceInfo = await getWorkspaceInfo(data.token)

// verify workspace url in the document matches the token
if (workspaceInfo.workspace !== workspaceId) {
if (workspaceInfo.workspaceId !== workspaceId) {
throw new Error('documentName must include workspace id')
}

Expand Down
4 changes: 2 additions & 2 deletions server/datalake/src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class Client {
constructor (private readonly endpoint: string) {}

getObjectUrl (ctx: MeasureContext, workspace: WorkspaceId, objectName: string): string {
const path = `/blob/${workspace.name}/${objectName}`
const path = `/blob/${workspace.name}/${encodeURIComponent(objectName)}`
return concatLink(this.endpoint, path)
}

Expand Down Expand Up @@ -91,7 +91,7 @@ export class Client {

const form = new FormData()
const options: FormData.AppendOptions = {
filename: objectName,
filename: encodeURIComponent(objectName),
contentType: metadata.type,
knownLength: metadata.size,
header: {
Expand Down

0 comments on commit 1502899

Please sign in to comment.