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/getSelectionData.js

35 lines
929 B

import { Meteor } from 'meteor/meteor';
import {
Importers,
ProgressStep,
} from '..';
import { hasPermission } from '../../../authorization';
Meteor.methods({
getSelectionData(key) {
if (!Meteor.userId()) {
throw new Meteor.Error('error-invalid-user', 'Invalid user', { method: 'getSelectionData' });
}
if (!hasPermission(Meteor.userId(), 'run-import')) {
throw new Meteor.Error('error-action-not-allowed', 'Importing is not allowed', { method: 'setupImporter' });
}
const importer = Importers.get(key);
if (!importer || !importer.instance) {
throw new Meteor.Error('error-importer-not-defined', `The importer (${ key }) has no import class defined.`, { method: 'getSelectionData' });
}
const progress = importer.instance.getProgress();
switch (progress.step) {
case ProgressStep.USER_SELECTION:
return importer.instance.getSelection();
default:
return undefined;
}
},
});