aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/src
diff options
context:
space:
mode:
authorskjnldsv <skjnldsv@protonmail.com>2024-12-20 12:45:50 +0100
committerskjnldsv <skjnldsv@protonmail.com>2025-01-09 12:54:51 +0100
commit771584f5c1af1116841e6a7b2732c8228e463509 (patch)
tree21e69ee43363a12ac3640f32766bfde157307b38 /apps/files_sharing/src
parentf753d2f77381560017e59934efe25b70ad6fbb80 (diff)
downloadnextcloud-server-771584f5c1af1116841e6a7b2732c8228e463509.tar.gz
nextcloud-server-771584f5c1af1116841e6a7b2732c8228e463509.zip
fix(files_sharing): external share parsing
Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
Diffstat (limited to 'apps/files_sharing/src')
-rw-r--r--apps/files_sharing/src/services/SharingService.spec.ts43
-rw-r--r--apps/files_sharing/src/services/SharingService.ts4
2 files changed, 47 insertions, 0 deletions
diff --git a/apps/files_sharing/src/services/SharingService.spec.ts b/apps/files_sharing/src/services/SharingService.spec.ts
index daba81bd4f2..fa805c28371 100644
--- a/apps/files_sharing/src/services/SharingService.spec.ts
+++ b/apps/files_sharing/src/services/SharingService.spec.ts
@@ -294,6 +294,20 @@ describe('SharingService share to Node mapping', () => {
accepted: true,
}
+ const tempExternalFile = {
+ id: 65,
+ share_type: 0,
+ parent: -1,
+ remote: 'http://nextcloud1.local/',
+ remote_id: '71',
+ share_token: '9GpiAmTIjayclrE',
+ name: '/test.md',
+ owner: 'owner-uid',
+ user: 'sharee-uid',
+ mountpoint: '{{TemporaryMountPointName#/test.md}}',
+ accepted: 0,
+ }
+
beforeEach(() => { vi.resetAllMocks() })
test('File', async () => {
@@ -384,6 +398,35 @@ describe('SharingService share to Node mapping', () => {
expect(file.attributes.favorite).toBe(0)
})
+ test('External temp file', async () => {
+ axios.get.mockReturnValueOnce(Promise.resolve({
+ data: {
+ ocs: {
+ data: [tempExternalFile],
+ },
+ },
+ }))
+
+ 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(65)
+ expect(file.source).toBe('http://nextcloud.local/remote.php/dav/files/test/test.md')
+ expect(file.owner).toBe('owner-uid')
+ expect(file.mime).toBe('text/markdown')
+ expect(file.mtime?.getTime()).toBe(undefined)
+ // 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('Empty', async () => {
vi.spyOn(logger, 'error').mockImplementationOnce(() => {})
axios.get.mockReturnValueOnce(Promise.resolve({
diff --git a/apps/files_sharing/src/services/SharingService.ts b/apps/files_sharing/src/services/SharingService.ts
index 2f8144e216e..2d1d5fbef9e 100644
--- a/apps/files_sharing/src/services/SharingService.ts
+++ b/apps/files_sharing/src/services/SharingService.ts
@@ -36,6 +36,10 @@ const ocsEntryToNode = async function(ocsEntry: any): Promise<Folder | File | nu
ocsEntry.item_mtime = ocsEntry.mtime
ocsEntry.file_target = ocsEntry.file_target || ocsEntry.mountpoint
+ if (ocsEntry.file_target.includes('TemporaryMountPointName')) {
+ ocsEntry.file_target = ocsEntry.name
+ }
+
// Need to set permissions to NONE for federated shares
ocsEntry.item_permissions = Permission.NONE
ocsEntry.permissions = Permission.NONE