The communications platform that puts data protection first.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
Rocket.Chat/app/importer/server/methods/getImportProgress.js

33 lines
1.1 KiB

import { Meteor } from 'meteor/meteor';
import { hasPermission } from '../../../authorization';
import { Imports } from '../../../models';
import { Importers } from '..';
Meteor.methods({
getImportProgress() {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getImportProgress' });
}
if (!hasPermission(Meteor.userId(), 'run-import')) {
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter' });
}
const operation = Imports.findLastImport();
if (!operation) {
throw new Meteor.Error('error-operation-not-found', 'Import Operation Not Found', { method: 'getImportProgress' });
}
const { importerKey } = operation;
const importer = Importers.get(importerKey);
if (!importer) {
throw new Meteor.Error('error-importer-not-defined', `The importer (${ importerKey }) has no import class defined.`, { method: 'getImportProgress' });
}
importer.instance = new importer.importer(importer, operation); // eslint-disable-line new-cap
return importer.instance.getProgress();
},
});