Skip to content

Commit d8eeccf

Browse files
provokateurinbackportbot[bot]
authored andcommitted
fix(files_sharing): Use share id in file actions
fix(files_sharing): Use share id in file actions Signed-off-by: provokateurin <kate@provokateurin.de> [skip ci]
1 parent 49db64f commit d8eeccf

7 files changed

Lines changed: 33 additions & 17 deletions

File tree

apps/files_sharing/src/files_actions/acceptShareAction.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ describe('Accept share action execute tests', () => {
151151
permissions: Permission.READ,
152152
attributes: {
153153
share_type: ShareType.User,
154+
'share-id': '1',
154155
},
155156
root: '/files/admin',
156157
})
@@ -164,7 +165,7 @@ describe('Accept share action execute tests', () => {
164165

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

169170
expect(eventBus.emit).toBeCalledTimes(1)
170171
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
@@ -183,6 +184,7 @@ describe('Accept share action execute tests', () => {
183184
attributes: {
184185
remote: 3,
185186
share_type: ShareType.User,
187+
'share-id': '1',
186188
},
187189
root: '/files/admin',
188190
})
@@ -196,7 +198,7 @@ describe('Accept share action execute tests', () => {
196198

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

201203
expect(eventBus.emit).toBeCalledTimes(1)
202204
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
@@ -214,6 +216,7 @@ describe('Accept share action execute tests', () => {
214216
permissions: Permission.READ,
215217
attributes: {
216218
share_type: ShareType.User,
219+
'share-id': '1',
217220
},
218221
root: '/files/admin',
219222
})
@@ -226,6 +229,7 @@ describe('Accept share action execute tests', () => {
226229
permissions: Permission.READ,
227230
attributes: {
228231
share_type: ShareType.User,
232+
'share-id': '2',
229233
},
230234
root: '/files/admin',
231235
})
@@ -239,8 +243,8 @@ describe('Accept share action execute tests', () => {
239243

240244
expect(exec).toStrictEqual([true, true])
241245
expect(axios.post).toBeCalledTimes(2)
242-
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/123')
243-
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/456')
246+
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/1')
247+
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/pending/2')
244248

245249
expect(eventBus.emit).toBeCalledTimes(2)
246250
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
@@ -260,6 +264,7 @@ describe('Accept share action execute tests', () => {
260264
permissions: Permission.READ,
261265
attributes: {
262266
share_type: ShareType.User,
267+
'share-id': '1',
263268
},
264269
root: '/files/admin',
265270
})
@@ -273,7 +278,7 @@ describe('Accept share action execute tests', () => {
273278

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

278283
expect(eventBus.emit).toBeCalledTimes(0)
279284
})

apps/files_sharing/src/files_actions/acceptShareAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export const action: IFileAction = {
2525
const isRemote = !!node.attributes.remote
2626
const url = generateOcsUrl('apps/files_sharing/api/v1/{shareBase}/pending/{id}', {
2727
shareBase: isRemote ? 'remote_shares' : 'shares',
28-
id: node.id,
28+
id: node.attributes['share-id'],
2929
})
3030
await axios.post(url)
3131

apps/files_sharing/src/files_actions/rejectShareAction.spec.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,7 @@ describe('Reject share action execute tests', () => {
195195
permissions: Permission.READ,
196196
attributes: {
197197
share_type: ShareType.User,
198+
'share-id': '1',
198199
},
199200
root: '/files/admin',
200201
})
@@ -208,7 +209,7 @@ describe('Reject share action execute tests', () => {
208209

209210
expect(exec).toBe(true)
210211
expect(axios.delete).toBeCalledTimes(1)
211-
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
212+
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')
212213

213214
expect(eventBus.emit).toBeCalledTimes(1)
214215
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
@@ -227,6 +228,7 @@ describe('Reject share action execute tests', () => {
227228
attributes: {
228229
remote: 3,
229230
share_type: ShareType.User,
231+
'share-id': '1',
230232
},
231233
root: '/files/admin',
232234
})
@@ -240,7 +242,7 @@ describe('Reject share action execute tests', () => {
240242

241243
expect(exec).toBe(true)
242244
expect(axios.delete).toBeCalledTimes(1)
243-
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/123')
245+
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/remote_shares/1')
244246

245247
expect(eventBus.emit).toBeCalledTimes(1)
246248
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
@@ -258,6 +260,7 @@ describe('Reject share action execute tests', () => {
258260
permissions: Permission.READ,
259261
attributes: {
260262
share_type: ShareType.User,
263+
'share-id': '1',
261264
},
262265
root: '/files/admin',
263266
})
@@ -270,6 +273,7 @@ describe('Reject share action execute tests', () => {
270273
permissions: Permission.READ,
271274
attributes: {
272275
share_type: ShareType.User,
276+
'share-id': '2',
273277
},
274278
root: '/files/admin',
275279
})
@@ -283,8 +287,8 @@ describe('Reject share action execute tests', () => {
283287

284288
expect(exec).toStrictEqual([true, true])
285289
expect(axios.delete).toBeCalledTimes(2)
286-
expect(axios.delete).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
287-
expect(axios.delete).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/456')
290+
expect(axios.delete).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')
291+
expect(axios.delete).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/2')
288292

289293
expect(eventBus.emit).toBeCalledTimes(2)
290294
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
@@ -304,6 +308,7 @@ describe('Reject share action execute tests', () => {
304308
permissions: Permission.READ,
305309
attributes: {
306310
share_type: ShareType.User,
311+
'share-id': '1',
307312
},
308313
root: '/files/admin',
309314
})
@@ -317,7 +322,7 @@ describe('Reject share action execute tests', () => {
317322

318323
expect(exec).toBe(false)
319324
expect(axios.delete).toBeCalledTimes(1)
320-
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/123')
325+
expect(axios.delete).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/shares/1')
321326

322327
expect(eventBus.emit).toBeCalledTimes(0)
323328
})

apps/files_sharing/src/files_actions/rejectShareAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export const action: IFileAction = {
4242
const node = nodes[0]
4343
const isRemote = !!node.attributes.remote
4444
const shareBase = isRemote ? 'remote_shares' : 'shares'
45-
const id = node.id
45+
const id = node.attributes['share-id']
4646
let url: string
4747
if (node.attributes.accepted === 0) {
4848
url = generateOcsUrl('apps/files_sharing/api/v1/{shareBase}/pending/{id}', {

apps/files_sharing/src/files_actions/restoreShareAction.spec.ts

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ describe('Restore share action execute tests', () => {
152152
permissions: Permission.READ,
153153
attributes: {
154154
share_type: ShareType.User,
155+
'share-id': '1',
155156
},
156157
root: '/files/admin',
157158
})
@@ -165,7 +166,7 @@ describe('Restore share action execute tests', () => {
165166

166167
expect(exec).toBe(true)
167168
expect(axios.post).toBeCalledTimes(1)
168-
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
169+
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')
169170

170171
expect(eventBus.emit).toBeCalledTimes(1)
171172
expect(eventBus.emit).toBeCalledWith('files:node:deleted', file)
@@ -183,6 +184,7 @@ describe('Restore share action execute tests', () => {
183184
permissions: Permission.READ,
184185
attributes: {
185186
share_type: ShareType.User,
187+
'share-id': '1',
186188
},
187189
root: '/files/admin',
188190
})
@@ -195,6 +197,7 @@ describe('Restore share action execute tests', () => {
195197
permissions: Permission.READ,
196198
attributes: {
197199
share_type: ShareType.User,
200+
'share-id': '2',
198201
},
199202
root: '/files/admin',
200203
})
@@ -208,8 +211,8 @@ describe('Restore share action execute tests', () => {
208211

209212
expect(exec).toStrictEqual([true, true])
210213
expect(axios.post).toBeCalledTimes(2)
211-
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
212-
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/456')
214+
expect(axios.post).toHaveBeenNthCalledWith(1, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')
215+
expect(axios.post).toHaveBeenNthCalledWith(2, 'http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/2')
213216

214217
expect(eventBus.emit).toBeCalledTimes(2)
215218
expect(eventBus.emit).toHaveBeenNthCalledWith(1, 'files:node:deleted', file1)
@@ -228,6 +231,7 @@ describe('Restore share action execute tests', () => {
228231
permissions: Permission.READ,
229232
attributes: {
230233
share_type: ShareType.User,
234+
'share-id': '1',
231235
},
232236
root: '/files/admin',
233237
})
@@ -241,7 +245,7 @@ describe('Restore share action execute tests', () => {
241245

242246
expect(exec).toBe(false)
243247
expect(axios.post).toBeCalledTimes(1)
244-
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/123')
248+
expect(axios.post).toBeCalledWith('http://nextcloud.local/ocs/v2.php/apps/files_sharing/api/v1/deletedshares/1')
245249

246250
expect(eventBus.emit).toBeCalledTimes(0)
247251
})

apps/files_sharing/src/files_actions/restoreShareAction.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export const action: IFileAction = {
2424
try {
2525
const node = nodes[0]
2626
const url = generateOcsUrl('apps/files_sharing/api/v1/deletedshares/{id}', {
27-
id: node.id,
27+
id: node.attributes['share-id'],
2828
})
2929
await axios.post(url)
3030

apps/files_sharing/src/services/SharingService.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ async function ocsEntryToNode(ocsEntry: any, unmounted = false): Promise<Folder
106106
root: getRootPath(),
107107
attributes: {
108108
...ocsEntry,
109+
// 'id' is a forbidden property name
110+
'share-id': ocsEntry.id,
109111
'has-preview': hasPreview,
110112
'hide-download': ocsEntry?.hide_download === 1,
111113
// Also check the sharingStatusAction.ts code

0 commit comments

Comments
 (0)