Skip to content
Open
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
15 changes: 10 additions & 5 deletions apps/files_sharing/src/files_actions/acceptShareAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ describe('Accept share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -164,7 +165,7 @@ describe('Accept share action execute tests', () => {

expect(exec).toBe(true)
expect(axios.post).toBeCalledTimes(1)
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123')
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/1')

expect(eventBus.emit).toBeCalledTimes(1)
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
Expand All @@ -183,6 +184,7 @@ describe('Accept share action execute tests', () => {
attributes: {
remote: 3,
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -196,7 +198,7 @@ describe('Accept share action execute tests', () => {

expect(exec).toBe(true)
expect(axios.post).toBeCalledTimes(1)
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/123')
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/pending/1')

expect(eventBus.emit).toBeCalledTimes(1)
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
Expand All @@ -214,6 +216,7 @@ describe('Accept share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -226,6 +229,7 @@ describe('Accept share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '2',
},
root: '/files/admin',
})
Expand All @@ -239,8 +243,8 @@ describe('Accept share action execute tests', () => {

expect(exec).toStrictEqual([true, true])
expect(axios.post).toBeCalledTimes(2)
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123')
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/456')
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/1')
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/2')

expect(eventBus.emit).toBeCalledTimes(2)
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
Expand All @@ -260,6 +264,7 @@ describe('Accept share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -273,7 +278,7 @@ describe('Accept share action execute tests', () => {

expect(exec).toBe(false)
expect(axios.post).toBeCalledTimes(1)
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123')
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/1')

expect(eventBus.emit).toBeCalledTimes(0)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export const action: IFileAction = {
const isRemote = !!node.attributes.remote
const url = generateOcsUrl('apps/files_sharing/api/v1/{shareBase}/pending/{id}', {
shareBase: isRemote ? 'remote_shares' : 'shares',
id: node.id,
id: node.attributes['share-id'],
})
await axios.post(url)

Expand Down
15 changes: 10 additions & 5 deletions apps/files_sharing/src/files_actions/rejectShareAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ describe('Reject share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -208,7 +209,7 @@ describe('Reject share action execute tests', () => {

expect(exec).toBe(true)
expect(axios.delete).toBeCalledTimes(1)
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')

expect(eventBus.emit).toBeCalledTimes(1)
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
Expand All @@ -227,6 +228,7 @@ describe('Reject share action execute tests', () => {
attributes: {
remote: 3,
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -240,7 +242,7 @@ describe('Reject share action execute tests', () => {

expect(exec).toBe(true)
expect(axios.delete).toBeCalledTimes(1)
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/123')
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/1')

expect(eventBus.emit).toBeCalledTimes(1)
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
Expand All @@ -258,6 +260,7 @@ describe('Reject share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -270,6 +273,7 @@ describe('Reject share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '2',
},
root: '/files/admin',
})
Expand All @@ -283,8 +287,8 @@ describe('Reject share action execute tests', () => {

expect(exec).toStrictEqual([true, true])
expect(axios.delete).toBeCalledTimes(2)
expect(axios.delete).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
expect(axios.delete).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/456')
expect(axios.delete).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')
expect(axios.delete).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/2')

expect(eventBus.emit).toBeCalledTimes(2)
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
Expand All @@ -304,6 +308,7 @@ describe('Reject share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -317,7 +322,7 @@ describe('Reject share action execute tests', () => {

expect(exec).toBe(false)
expect(axios.delete).toBeCalledTimes(1)
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')

expect(eventBus.emit).toBeCalledTimes(0)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const action: IFileAction = {
const node = nodes[0]
const isRemote = !!node.attributes.remote
const shareBase = isRemote ? 'remote_shares' : 'shares'
const id = node.id
const id = node.attributes['share-id']
let url: string
if (node.attributes.accepted === 0) {
url = generateOcsUrl('apps/files_sharing/api/v1/{shareBase}/pending/{id}', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ describe('Restore share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -165,7 +166,7 @@ describe('Restore share action execute tests', () => {

expect(exec).toBe(true)
expect(axios.post).toBeCalledTimes(1)
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')

expect(eventBus.emit).toBeCalledTimes(1)
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
Expand All @@ -183,6 +184,7 @@ describe('Restore share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -195,6 +197,7 @@ describe('Restore share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '2',
},
root: '/files/admin',
})
Expand All @@ -208,8 +211,8 @@ describe('Restore share action execute tests', () => {

expect(exec).toStrictEqual([true, true])
expect(axios.post).toBeCalledTimes(2)
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/456')
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/2')

expect(eventBus.emit).toBeCalledTimes(2)
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
Expand All @@ -228,6 +231,7 @@ describe('Restore share action execute tests', () => {
permissions: Permission.READ,
attributes: {
share_type: ShareType.User,
'share-id': '1',
},
root: '/files/admin',
})
Expand All @@ -241,7 +245,7 @@ describe('Restore share action execute tests', () => {

expect(exec).toBe(false)
expect(axios.post).toBeCalledTimes(1)
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')

expect(eventBus.emit).toBeCalledTimes(0)
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const action: IFileAction = {
try {
const node = nodes[0]
const url = generateOcsUrl('apps/files_sharing/api/v1/deletedshares/{id}', {
id: node.id,
id: node.attributes['share-id'],

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least on API level it seems to expect provider:id and id needs to be the group share ID and not the user-group share ID, e.g.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked what share-id resolves to here. It comes from ocsEntry.id, which for deleted shares is DeletedShareAPIController's $share->getFullId(), so it is already provider:id. For group shares resolveGroupShares() keeps the parent group share, so getFullId() returns the group id. So the action already sends provider:groupShareId

})
await axios.post(url)

Expand Down
2 changes: 2 additions & 0 deletions apps/files_sharing/src/services/SharingService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ async function ocsEntryToNode(ocsEntry: any, unmounted = false): Promise<Folder
root: getRootPath(),
attributes: {
...ocsEntry,
// 'id' is a forbidden property name
'share-id': ocsEntry.id,
'has-preview': hasPreview,
'hide-download': ocsEntry?.hide_download === 1,
// Also check the sharingStatusAction.ts code
Expand Down
Loading