diff options
author | provokateurin <kate@provokateurin.de> | 2025-01-21 15:08:07 +0100 |
---|---|---|
committer | backportbot[bot] <backportbot[bot]@users.noreply.github.com> | 2025-01-30 14:27:24 +0000 |
commit | 3654fb53e22a137ab9603039ad827efd2a70a553 (patch) | |
tree | 589ef741b8654006c70b9d28f90663e032c9bceb | |
parent | 27efd04c282fc035b4748e1d2da60de4fd549aa6 (diff) | |
download | nextcloud-server-3654fb53e22a137ab9603039ad827efd2a70a553.tar.gz nextcloud-server-3654fb53e22a137ab9603039ad827efd2a70a553.zip |
fix(files_sharing): Only clear permissions of pending federated shares
Signed-off-by: provokateurin <kate@provokateurin.de>
-rw-r--r-- | apps/files_sharing/src/services/SharingService.spec.ts | 102 | ||||
-rw-r--r-- | apps/files_sharing/src/services/SharingService.ts | 9 |
2 files changed, 82 insertions, 29 deletions
diff --git a/apps/files_sharing/src/services/SharingService.spec.ts b/apps/files_sharing/src/services/SharingService.spec.ts index fa805c28371..2224a1d3967 100644 --- a/apps/files_sharing/src/services/SharingService.spec.ts +++ b/apps/files_sharing/src/services/SharingService.spec.ts @@ -275,7 +275,7 @@ describe('SharingService share to Node mapping', () => { tags: [TAG_FAVORITE], } - const remoteFile = { + const remoteFileAccepted = { mimetype: 'text/markdown', mtime: 1688721600, permissions: 19, @@ -294,6 +294,25 @@ describe('SharingService share to Node mapping', () => { accepted: true, } + const remoteFilePending = { + mimetype: 'text/markdown', + mtime: 1688721600, + permissions: 19, + type: 'file', + file_id: 1234, + id: 4, + share_type: ShareType.User, + parent: null, + remote: 'http://exampe.com', + remote_id: '12345', + share_token: 'share-token', + name: '/test.md', + mountpoint: '/shares/test.md', + owner: 'owner-uid', + user: 'sharee-uid', + accepted: false, + } + const tempExternalFile = { id: 65, share_type: 0, @@ -369,33 +388,64 @@ describe('SharingService share to Node mapping', () => { expect(folder.attributes.favorite).toBe(1) }) - test('Remote file', async () => { - axios.get.mockReturnValueOnce(Promise.resolve({ - data: { - ocs: { - data: [remoteFile], + describe('Remote file', () => { + test('Accepted', async () => { + axios.get.mockReturnValueOnce(Promise.resolve({ + data: { + ocs: { + data: [remoteFileAccepted], + }, }, - }, - })) - - const shares = await getContents(false, true, false, false) - - expect(axios.get).toHaveBeenCalledTimes(1) - expect(shares.contents).toHaveLength(1) + })) + + const shares = await getContents(false, true, false, false) + + expect(axios.get).toHaveBeenCalledTimes(1) + expect(shares.contents).toHaveLength(1) + + const file = shares.contents[0] as File + expect(file).toBeInstanceOf(File) + expect(file.fileid).toBe(1234) + expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md') + expect(file.owner).toBe('owner-uid') + expect(file.mime).toBe('text/markdown') + expect(file.mtime?.getTime()).toBe(remoteFileAccepted.mtime * 1000) + // not available for remote shares + expect(file.size).toBe(undefined) + expect(file.permissions).toBe(19) + expect(file.root).toBe('/files/test') + expect(file.attributes).toBeInstanceOf(Object) + expect(file.attributes.favorite).toBe(0) + }) - const file = shares.contents[0] as File - expect(file).toBeInstanceOf(File) - expect(file.fileid).toBe(1234) - expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md') - expect(file.owner).toBe('owner-uid') - expect(file.mime).toBe('text/markdown') - expect(file.mtime?.getTime()).toBe(remoteFile.mtime * 1000) - // not available for remote shares - expect(file.size).toBe(undefined) - expect(file.permissions).toBe(0) - expect(file.root).toBe('/files/test') - expect(file.attributes).toBeInstanceOf(Object) - expect(file.attributes.favorite).toBe(0) + test('Pending', async () => { + axios.get.mockReturnValueOnce(Promise.resolve({ + data: { + ocs: { + data: [remoteFilePending], + }, + }, + })) + + const shares = await getContents(false, true, false, false) + + expect(axios.get).toHaveBeenCalledTimes(1) + expect(shares.contents).toHaveLength(1) + + const file = shares.contents[0] as File + expect(file).toBeInstanceOf(File) + expect(file.fileid).toBe(1234) + expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/test.md') + expect(file.owner).toBe('owner-uid') + expect(file.mime).toBe('text/markdown') + expect(file.mtime?.getTime()).toBe(remoteFilePending.mtime * 1000) + // not available for remote shares + expect(file.size).toBe(undefined) + expect(file.permissions).toBe(0) + expect(file.root).toBe('/files/test') + expect(file.attributes).toBeInstanceOf(Object) + expect(file.attributes.favorite).toBe(0) + }) }) test('External temp file', async () => { diff --git a/apps/files_sharing/src/services/SharingService.ts b/apps/files_sharing/src/services/SharingService.ts index 2d1d5fbef9e..01a92cfff87 100644 --- a/apps/files_sharing/src/services/SharingService.ts +++ b/apps/files_sharing/src/services/SharingService.ts @@ -40,9 +40,12 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu ocsEntry.file_target = ocsEntry.name } - // Need to set permissions to NONE for federated shares - ocsEntry.item_permissions = Permission.NONE - ocsEntry.permissions = Permission.NONE + // If the share is not accepted yet we don't know which permissions it will have + if (!ocsEntry.accepted) { + // Need to set permissions to NONE for federated shares + ocsEntry.item_permissions = Permission.NONE + ocsEntry.permissions = Permission.NONE + } ocsEntry.uid_owner = ocsEntry.owner // TODO: have the real display name stored somewhere |