wekan/models/import.js
Benjamin Tissoires 35ffd02814 Fix import error 500
while running an import from a previously exported board, we encounter
the following error:

Exception while invoking method 'importBoard' Error: Did not check() all arguments during call to 'importBoard'
    at ArgumentChecker.throwUnlessAllArgumentsHaveBeenChecked (packages/check.js:483:13)
    at Object._failIfArgumentsAreNotAllChecked (packages/check.js:131:16)
    at maybeAuditArgumentChecks (packages/ddp-server/livedata_server.js:1765:18)
    at DDP._CurrentMethodInvocation.withValue (packages/ddp-server/livedata_server.js:719:19)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at DDPServer._CurrentWriteFence.withValue (packages/ddp-server/livedata_server.js:717:46)
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Promise (packages/ddp-server/livedata_server.js:715:46)
    at new Promise (<anonymous>)
    at Session.method (packages/ddp-server/livedata_server.js:689:23)
    at packages/mdg_meteor-apm-agent.js:2617:38
    at Meteor.EnvironmentVariable.EVp.withValue (packages/meteor.js:1186:15)
    at Session.sessionProto.protocol_handlers.method (packages/mdg_meteor-apm-agent.js:2616:44)
    at packages/ddp-server/livedata_server.js:559:43

Commit 4cf9813449 removed the checks as the original board might
not have all the required fields, but we actually still need to run
a general check on all parameters
2019-03-11 11:42:05 +01:00

29 lines
834 B
JavaScript

import { TrelloCreator } from './trelloCreator';
import { WekanCreator } from './wekanCreator';
Meteor.methods({
importBoard(board, data, importSource, currentBoard) {
check(board, Object);
check(data, Object);
check(importSource, String);
check(currentBoard, Match.Maybe(String));
let creator;
switch (importSource) {
case 'trello':
creator = new TrelloCreator(data);
break;
case 'wekan':
creator = new WekanCreator(data);
break;
}
// 1. check all parameters are ok from a syntax point of view
//creator.check(board);
// 2. check parameters are ok from a business point of view (exist &
// authorized) nothing to check, everyone can import boards in their account
// 3. create all elements
return creator.create(board, currentBoard);
},
});