Browse Source

Merge pull request #56977 from nextcloud/fix/federated-share-display-in-shared-with-you

fix(files_sharing): Normalize dir type to folder for federated shares
chore/files-4-0-0-review
F. E Noel Nfebe 8 months ago
committed by GitHub
parent
commit
d15feb4ba6
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 49
      apps/files_sharing/src/services/SharingService.spec.ts
  2. 3
      apps/files_sharing/src/services/SharingService.ts
  3. 2
      dist/5230-5230.js.map
  4. 4
      dist/files_sharing-init.js
  5. 2
      dist/files_sharing-init.js.map

49
apps/files_sharing/src/services/SharingService.spec.ts

@ -313,6 +313,25 @@ describe('SharingService share to Node mapping', () => {
accepted: false,
}
const remoteFolderAccepted = {
mimetype: 'httpd/unix-directory',
mtime: 1688721600,
permissions: 31,
type: 'dir',
file_id: 5678,
id: 5,
share_type: ShareType.User,
parent: null,
remote: 'http://example.com',
remote_id: '12346',
share_token: 'share-token-folder',
name: '/testfolder',
mountpoint: '/shares/testfolder',
owner: 'owner-uid',
user: 'sharee-uid',
accepted: true,
}
const tempExternalFile = {
id: 65,
share_type: 0,
@ -457,6 +476,36 @@ describe('SharingService share to Node mapping', () => {
})
})
describe('Remote folder', () => {
test('Accepted with type dir', async () => {
axios.get.mockReturnValueOnce(Promise.resolve({
data: {
ocs: {
data: [remoteFolderAccepted],
},
},
}))
const shares = await getContents(false, true, false, false)
expect(axios.get).toHaveBeenCalledTimes(1)
expect(shares.contents).toHaveLength(1)
const folder = shares.contents[0] as Folder
expect(folder).toBeInstanceOf(Folder)
expect(folder.fileid).toBe(5678)
expect(folder.source).toBe('http://nextcloud.local/remote.php/dav/files/test/shares/testfolder')
expect(folder.owner).toBe('owner-uid')
expect(folder.mime).toBe('httpd/unix-directory')
expect(folder.mtime?.getTime()).toBe(remoteFolderAccepted.mtime * 1000)
expect(folder.size).toBe(undefined)
expect(folder.permissions).toBe(31)
expect(folder.root).toBe('/files/test')
expect(folder.attributes).toBeInstanceOf(Object)
expect(folder.attributes.favorite).toBe(0)
})
})
test('External temp file', async () => {
axios.get.mockReturnValueOnce(Promise.resolve({
data: {

3
apps/files_sharing/src/services/SharingService.ts

@ -33,7 +33,8 @@ async function ocsEntryToNode(ocsEntry: any): Promise<Folder | File | null> {
// This won't catch files without an extension, but this is the best we can do
ocsEntry.mimetype = mime.getType(ocsEntry.name)
}
ocsEntry.item_type = ocsEntry.type || (ocsEntry.mimetype ? 'file' : 'folder')
const type = ocsEntry.type === 'dir' ? 'folder' : ocsEntry.type
ocsEntry.item_type = type || (ocsEntry.mimetype ? 'file' : 'folder')
// different naming for remote shares
ocsEntry.item_mtime = ocsEntry.mtime

2
dist/5230-5230.js.map
File diff suppressed because it is too large
View File

4
dist/files_sharing-init.js
File diff suppressed because it is too large
View File

2
dist/files_sharing-init.js.map
File diff suppressed because it is too large
View File

Loading…
Cancel
Save