Skip to content

Commit

Permalink
fix: Properly handle public shares for davResultToNode
Browse files Browse the repository at this point in the history
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
  • Loading branch information
susnux committed Jun 18, 2024
1 parent 607066d commit c386ac9
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/dav/dav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { DAVResultResponseProps, FileStat, ResponseDataDetailed, WebDAVClient } from 'webdav'
import { NodeStatus, type Node } from '../files/node'
import type { Node } from '../files/node'

import { File } from '../files/file'
import { Folder } from '../files/folder'
import { NodeStatus } from '../files/node'
import { NodeData } from '../files/nodeData'
import { davParsePermissions } from './davPermissions'
import { davGetFavoritesReport } from './davProperties'

import { getCurrentUser, getRequestToken, onRequestTokenUpdate } from '@nextcloud/auth'
import { generateRemoteUrl } from '@nextcloud/router'
import { createClient, getPatcher } from 'webdav'
import { CancelablePromise } from 'cancelable-promise'
import { createClient, getPatcher } from 'webdav'
import { isPublicShare } from '../utils/isPublic'

/**
* Nextcloud DAV result response
Expand Down Expand Up @@ -137,9 +139,7 @@ export const getFavoriteNodes = (davClient: WebDAVClient, path = '/', davRoot =
*/
export const davResultToNode = function(node: FileStat, filesRoot = davRootPath, remoteURL = davRemoteURL): Node {
let userId = getCurrentUser()?.uid
const isPublic = document.querySelector<HTMLInputElement>('input#isPublic')?.value
if (isPublic) {
userId = userId ?? document.querySelector<HTMLInputElement>('input#sharingUserId')?.value
if (isPublicShare()) {
userId = userId ?? 'anonymous'
} else if (!userId) {
throw new Error('No user id found')

Check failure on line 145 in lib/dav/dav.ts

View workflow job for this annotation

GitHub Actions / test

__tests__/dav/dav.spec.ts > davResultToNode > has correct owner set on public shares

Error: No user id found ❯ Module.davResultToNode lib/dav/dav.ts:145:9 ❯ __tests__/dav/dav.spec.ts:133:16

Check failure on line 145 in lib/dav/dav.ts

View workflow job for this annotation

GitHub Actions / test

__tests__/dav/dav.spec.ts > davResultToNode > by default no status is set

Error: No user id found ❯ Module.davResultToNode lib/dav/dav.ts:145:9 ❯ __tests__/dav/dav.spec.ts:142:16

Check failure on line 145 in lib/dav/dav.ts

View workflow job for this annotation

GitHub Actions / test

__tests__/dav/dav.spec.ts > davResultToNode > sets node status on invalid fileid

Error: No user id found ❯ Module.davResultToNode lib/dav/dav.ts:145:9 ❯ __tests__/dav/dav.spec.ts:149:16
Expand Down

0 comments on commit c386ac9

Please sign in to comment.