mirror of https://github.com/sualko/cloud_bbb
fix: do not register file action without authentication
parent
cc566608b2
commit
dedfd37cae
|
@ -2,8 +2,6 @@ import axios from '@nextcloud/axios';
|
||||||
import { generateOcsUrl, generateUrl } from '@nextcloud/router';
|
import { generateOcsUrl, generateUrl } from '@nextcloud/router';
|
||||||
import { api } from './Common/Api';
|
import { api } from './Common/Api';
|
||||||
|
|
||||||
declare const OCA: any;
|
|
||||||
|
|
||||||
const mimeTypes = [
|
const mimeTypes = [
|
||||||
'application/pdf',
|
'application/pdf',
|
||||||
'application/vnd.oasis.opendocument.presentation',
|
'application/vnd.oasis.opendocument.presentation',
|
||||||
|
@ -42,8 +40,8 @@ async function share(fileId: number, filename: string, roomUid) {
|
||||||
window.open(joinUrl, '_blank', 'noopener,noreferrer');
|
window.open(joinUrl, '_blank', 'noopener,noreferrer');
|
||||||
}
|
}
|
||||||
|
|
||||||
function registerFileAction(mime, id, uid, name) {
|
function registerFileAction(fileActions, mime, id, uid, name) {
|
||||||
OCA.Files.fileActions.registerAction({
|
fileActions.registerAction({
|
||||||
name: 'bbb-' + id,
|
name: 'bbb-' + id,
|
||||||
displayName: name,
|
displayName: name,
|
||||||
mime,
|
mime,
|
||||||
|
@ -55,22 +53,22 @@ function registerFileAction(mime, id, uid, name) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addRoomsAsFileAction() {
|
const BBBFileListPlugin = {
|
||||||
if (!OCA?.Files?.fileActions) {
|
ignoreLists: [
|
||||||
console.warn('[BBB] "OCA.Files.fileActions" not available');
|
'trashbin',
|
||||||
|
],
|
||||||
|
|
||||||
|
attach(fileList) {
|
||||||
|
if (this.ignoreLists.includes(fileList.id) || !OC.currentUser) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
api.getRooms().then(rooms => {
|
api.getRooms().then(rooms => {
|
||||||
rooms.forEach(room => {
|
rooms.forEach(room => {
|
||||||
mimeTypes.forEach(mime => registerFileAction(mime, room.id, room.uid, room.name));
|
mimeTypes.forEach(mime => registerFileAction(fileList.fileActions, mime, room.id, room.uid, room.name));
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
|
};
|
||||||
|
|
||||||
if (document.readyState === 'complete') {
|
OC.Plugins.register('OCA.Files.FileList', BBBFileListPlugin);
|
||||||
addRoomsAsFileAction();
|
|
||||||
} else {
|
|
||||||
document.addEventListener('DOMContentLoaded', addRoomsAsFileAction);
|
|
||||||
}
|
|
Loading…
Reference in New Issue