Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .woodpecker.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# The version of OpenCloud to use in pipelines
OPENCLOUD_COMMITID=9e16bb9e2909a2af0d66ef2c6388e9b885e20f1c
OPENCLOUD_COMMITID=cca5d1af043531dc84cb0aa3e67f9795b1a1caa3
OPENCLOUD_BRANCH=main
12 changes: 7 additions & 5 deletions packages/web-app-external/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ import {
FilePickerModal
} from '@opencloud-eu/web-pkg'
import FileNameModal from './components/FileNameModal.vue'
import { DavProperty } from '@opencloud-eu/web-client/webdav'

const { space, resource, isReadOnly } = defineProps<{
space: SpaceResource
Expand All @@ -101,9 +102,8 @@ const appProviderService = useAppProviderService()
const { makeRequest } = useRequest()
const spacesStore = useSpacesStore()
const sharesStore = useSharesStore()
const { graphAuthenticated: graphClient } = useClientService()
const { graphAuthenticated: graphClient, webdav } = useClientService()
const { dispatchModal } = useModals()
const { webdav } = useClientService()
const { currentTheme } = useThemeStore()
const { getParentFolderLink } = useFolderLink()

Expand Down Expand Up @@ -337,10 +337,12 @@ const handlePostMessagesCollabora = async (event: MessageEvent) => {
customComponentAttrs: () => ({
parentFolderLink: getParentFolderLink(resource),
allowedFileTypes: ['image/png', 'image/gif', 'image/jpeg', 'image/svg'],
callbackFn: ({ resource }: { resource: Resource }) => {
postMessageToCollabora('Action_InsertGraphic', {
url: resource.downloadURL
callbackFn: async ({ resource }: { resource: Resource }) => {
const { downloadURL: url } = await webdav.getFileInfo(space, resource, {
davProperties: [DavProperty.DownloadURL]
})

postMessageToCollabora('Action_InsertGraphic', { url })
}
}),
focusTrapInitial: false
Expand Down
39 changes: 0 additions & 39 deletions packages/web-app-files/src/helpers/user/avatarUrl.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/web-app-files/src/helpers/user/index.ts

This file was deleted.

74 changes: 0 additions & 74 deletions packages/web-app-files/tests/unit/helpers/user/avatarUrl.spec.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/web-client/src/webdav/constants/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ export abstract class DavProperties {
DavProperty.ETag,
DavProperty.MimeType,
DavProperty.ResourceType,
DavProperty.DownloadURL,
DavProperty.Tags,
DavProperty.Audio,
DavProperty.Location,
Expand Down
49 changes: 25 additions & 24 deletions packages/web-client/src/webdav/getFileUrl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@ import { GetFileContentsFactory } from './getFileContents'
import { WebDavOptions } from './types'
import { DAV, DAVRequestOptions } from './client'
import { ocs } from '../ocs'
import { GetFileInfoFactory } from './getFileInfo'
import { DavProperty } from './constants'

export const GetFileUrlFactory = (
dav: DAV,
getFileContentsFactory: ReturnType<typeof GetFileContentsFactory>,
getFileInfoFactory: ReturnType<typeof GetFileInfoFactory>,
{ axiosClient, baseUrl }: WebDavOptions
) => {
return {
Expand All @@ -29,47 +32,45 @@ export const GetFileUrlFactory = (
/** @deprecated this has no effect */
signUrlTimeout?: number
version?: string
/** @deprecated */
doHeadRequest?: boolean
username?: string
} & DAVRequestOptions
): Promise<string> {
const inlineDisposition = disposition === 'inline'
let { downloadURL } = resource

if (!downloadURL && !inlineDisposition) {
// compute unsigned url
downloadURL = version
? dav.getFileUrl(urlJoin('meta', resource.fileId, 'v', version))
: dav.getFileUrl(resource.webDavPath)

if (username) {
if (doHeadRequest) {
await axiosClient.head(downloadURL)
}

const ocsClient = ocs(baseUrl, axiosClient)
downloadURL = await ocsClient.signUrl(downloadURL, username)
}
}

// FIXME: re-introduce query parameters
// They are not supported by getFileContents() and as we don't need them right now, I'm disabling the feature completely for now
//
// // Since the pre-signed url contains query parameters and the caller of this method
// // can also provide query parameters we have to combine them.
// Since the pre-signed url contains query parameters and the caller of this method
// can also provide query parameters we have to combine them.
// const queryStr = qs.stringify(options.query || null)
// const [url, signedQuery] = downloadURL.split('?')
// const combinedQuery = [queryStr, signedQuery].filter(Boolean).join('&')
// downloadURL = [url, combinedQuery].filter(Boolean).join('?')

if (inlineDisposition) {
if (disposition === 'inline') {
const response = await getFileContentsFactory.getFileContents(space, resource, {
responseType: 'blob',
...opts
})
downloadURL = URL.createObjectURL(response.body)
return URL.createObjectURL(response.body)
}

if (version) {
if (!username) {
throw new Error('username is required for URL signing')
}
// FIXME: remove as soon as we remove client side url signing https://github.com/opencloud-eu/opencloud/issues/1197
const downloadURL = dav.getFileUrl(urlJoin('meta', resource.fileId, 'v', version))
const ocsClient = ocs(baseUrl, axiosClient)
return await ocsClient.signUrl(downloadURL, username)
}

if (resource.downloadURL) {
return resource.downloadURL
}

const { downloadURL } = await getFileInfoFactory.getFileInfo(space, resource, {
davProperties: [DavProperty.DownloadURL]
})
return downloadURL
},
revokeUrl: (url: string) => {
Expand Down
7 changes: 6 additions & 1 deletion packages/web-client/src/webdav/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,12 @@ export const webdav = (baseURI: string, headers?: () => Headers): WebDAV => {
const { getFileContents } = getFileContentsFactory
const { putFileContents } = PutFileContentsFactory(dav, getFileInfoFactory, options)

const { getFileUrl, revokeUrl } = GetFileUrlFactory(dav, getFileContentsFactory, options)
const { getFileUrl, revokeUrl } = GetFileUrlFactory(
dav,
getFileContentsFactory,
getFileInfoFactory,
options
)
const { getPublicFileUrl } = GetPublicFileUrlFactory(dav, options)

const { copyFiles } = CopyFilesFactory(dav, options)
Expand Down
2 changes: 1 addition & 1 deletion packages/web-client/src/webdav/listFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export const ListFilesFactory = (
const resources = webDavResources.map((r) => buildResource(r, dav.extraProps))

const resourceIsSpace = fileId === space.id
if (fileId && !resourceIsSpace && fileId !== resources[0].fileId) {
if (fileId && !resourceIsSpace && resources[0].fileId && fileId !== resources[0].fileId) {
return listFilesCorrectedPath()
}
return { resource: resources[0], children: resources.slice(1) } as ListFilesResult
Expand Down
1 change: 1 addition & 0 deletions packages/web-pkg/src/services/cache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ const avatarUrlCache = new Cache<
>({ ttl: 10 * 1000, capacity: 250 })

class CacheService {
/** @deprecated */
public get avatarUrl() {
return avatarUrlCache
}
Expand Down
8 changes: 7 additions & 1 deletion packages/web-pkg/src/services/folder/loaders/loaderSpace.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { DriveItem } from '@opencloud-eu/web-client/graph/generated'
import { isLocationSpacesActive, isLocationPublicActive } from '../../../router'
import { getSharedDriveItem, setCurrentUserShareSpacePermissions } from '../../../helpers'
import { useFileRouteReplace } from '../../../composables'
import { DavProperties, DavProperty } from '@opencloud-eu/web-client/webdav'

export class FolderLoaderSpace implements FolderLoader {
public isEnabled(): boolean {
Expand Down Expand Up @@ -57,9 +58,14 @@ export class FolderLoaderSpace implements FolderLoader {
try {
resourcesStore.clearResourceList()

const davProperties = DavProperties.Default
if (isPublicSpaceResource(space)) {
// needed for public links for make previews work
davProperties.push(DavProperty.DownloadURL)
}
// eslint-disable-next-line prefer-const
let { resource: currentFolder, children: resources } = yield* call(
webdav.listFiles(space, { path, fileId }, { signal: signal1 })
webdav.listFiles(space, { path, fileId }, { signal: signal1, davProperties })
)
// if current folder has no id (= singe file public link) we must not correct the route
if (currentFolder.id) {
Expand Down
12 changes: 10 additions & 2 deletions packages/web-pkg/src/services/preview/previewService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { isPublicSpaceResource } from '@opencloud-eu/web-client'
import { BuildQueryStringOptions, LoadPreviewOptions } from '.'
import { AuthStore, ConfigStore, UserStore } from '../../composables' // @ts-ignore
import { stringify } from 'qs'
import { DavProperty } from '@opencloud-eu/web-client/webdav'

export class PreviewService {
clientService: ClientService
Expand Down Expand Up @@ -147,10 +148,17 @@ export class PreviewService {
options: LoadPreviewOptions,
signal?: AbortSignal
): Promise<string> {
const { resource, dimensions, processor } = options
const { space, resource, dimensions, processor } = options
let { downloadURL } = resource
if (!downloadURL) {
const { downloadURL: url } = await this.clientService.webdav.getFileInfo(space, resource, {
davProperties: [DavProperty.DownloadURL]
})
downloadURL = url
}
// In a public context, i.e. public shares, the downloadURL contains a pre-signed url to
// download the file.
const [url, signedQuery] = resource.downloadURL.split('?')
const [url, signedQuery] = downloadURL.split('?')

// Since the pre-signed url contains query parameters and the caller of this method
// can also provide query parameters we have to combine them.
Expand Down
5 changes: 0 additions & 5 deletions packages/web-pkg/tests/unit/services/cache.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,5 @@ describe('cache', () => {
const filePreviewCache = cacheService.filePreview
expect(filePreviewCache).toBeInstanceOf(Cache)
})

test('avatarUrl', () => {
const avatarUrlCache = cacheService.avatarUrl
expect(avatarUrlCache).toBeInstanceOf(Cache)
})
})
})
Loading