Skip to content

Commit a79dd9f

Browse files
committed
feat: Disable copy and download files actions
Signed-off-by: Louis Chemineau <[email protected]>
1 parent c11ecc3 commit a79dd9f

File tree

1 file changed

+22
-1
lines changed

1 file changed

+22
-1
lines changed

src/files.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,35 @@
44
*/
55

66
import { loadState } from '@nextcloud/initial-state'
7-
import { registerFileAction } from '@nextcloud/files'
7+
import { registerFileAction, getFileActions, Node, View } from '@nextcloud/files'
88

99
import { setupWebDavDecryptionProxy } from './services/webDavProxy.ts'
1010
import downloadUnencryptedAction from './services/downloadUnencryptedAction.ts'
11+
import logger from './services/logger.ts'
1112

1213
const userConfig = loadState('end_to_end_encryption', 'userConfig', { e2eeInBrowserEnabled: false })
1314

1415
if (userConfig.e2eeInBrowserEnabled) {
1516
setupWebDavDecryptionProxy()
1617
registerFileAction(downloadUnencryptedAction)
18+
disableFileAction('download')
19+
disableFileAction('move-copy')
1720
}
21+
22+
function disableFileAction(actionId: string) {
23+
logger.debug('Disabling file action', { actionId })
24+
const actions = getFileActions()
25+
26+
const action = actions.find(action => action.id === actionId) as any
27+
const originalEnabled = action._action.enabled
28+
29+
action._action.enabled = (nodes: Node[], view: View) => {
30+
console.log(view, nodes)
31+
32+
if (nodes.some(node => node.attributes['is-encrypted'] === 1)) {
33+
return false
34+
}
35+
36+
return originalEnabled(nodes, view)
37+
}
38+
}

0 commit comments

Comments
 (0)