diff options
Diffstat (limited to 'models')
-rw-r--r-- | models/settings.js | 8 | ||||
-rw-r--r-- | models/trelloCreator.js | 27 |
2 files changed, 33 insertions, 2 deletions
diff --git a/models/settings.js b/models/settings.js index 63bcd7f3..0d671aa4 100644 --- a/models/settings.js +++ b/models/settings.js @@ -198,6 +198,10 @@ if (Meteor.isServer) { return process.env.CAS_ENABLED === 'true'; } + function isApiEnabled() { + return process.env.WITH_API === 'true'; + } + Meteor.methods({ sendInvitation(emails, boards) { check(emails, [String]); @@ -314,6 +318,10 @@ if (Meteor.isServer) { return isCasEnabled(); }, + _isApiEnabled() { + return isApiEnabled(); + }, + // Gets all connection methods to use it in the Template getAuthenticationsEnabled() { return { diff --git a/models/trelloCreator.js b/models/trelloCreator.js index cb1a6a67..48dce7eb 100644 --- a/models/trelloCreator.js +++ b/models/trelloCreator.js @@ -1,4 +1,4 @@ -const DateString = Match.Where(function(dateAsString) { +const DateString = Match.Where(function (dateAsString) { check(dateAsString, String); return moment(dateAsString, moment.ISO_8601).isValid(); }); @@ -285,6 +285,29 @@ export class TrelloCreator { cardToCreate.members = wekanMembers; } } + // add vote + if (card.idMembersVoted) { + // Trello only know's positive votes + const positiveVotes = []; + card.idMembersVoted.forEach(trelloId => { + if (this.members[trelloId]) { + const wekanId = this.members[trelloId]; + // we may map multiple Trello members to the same wekan user + // in which case we risk adding the same user multiple times + if (!positiveVotes.find(wId => wId === wekanId)) { + positiveVotes.push(wekanId); + } + } + return true; + }) + if (positiveVotes.length > 0) { + cardToCreate.vote = { + question: cardToCreate.title, + positive: positiveVotes, + } + } + } + // insert card const cardId = Cards.direct.insert(cardToCreate); // keep track of Trello id => Wekan id @@ -345,7 +368,7 @@ export class TrelloCreator { // so we make it server only, and let UI catch up once it is done, forget about latency comp. const self = this; if (Meteor.isServer) { - file.attachData(att.url, function(error) { + file.attachData(att.url, function (error) { file.boardId = boardId; file.cardId = cardId; file.userId = self._user(att.idMemberCreator); |