summaryrefslogtreecommitdiffstats
path: root/models/import.js
diff options
context:
space:
mode:
authorXavier Priour <xavier.priour@bubblyware.com>2015-10-14 19:54:40 +0200
committerMaxime Quandalle <maxime@quandalle.com>2015-10-14 23:23:16 +0200
commit7d57ce896baeac74498e8b76b5812ceb6df8b950 (patch)
treeb9ee501ebd7ea83dfe9ca98e7c4b5f34e0d1e16b /models/import.js
parent4b99ce2aa2ed94d54f677f94e410d2888aa3491f (diff)
downloadwekan-7d57ce896baeac74498e8b76b5812ceb6df8b950.tar.gz
wekan-7d57ce896baeac74498e8b76b5812ceb6df8b950.tar.bz2
wekan-7d57ce896baeac74498e8b76b5812ceb6df8b950.zip
Import single card: create an 'importCard' activity entry
Diffstat (limited to 'models/import.js')
-rw-r--r--models/import.js30
1 files changed, 22 insertions, 8 deletions
diff --git a/models/import.js b/models/import.js
index a4172c0d..a76bbc5f 100644
--- a/models/import.js
+++ b/models/import.js
@@ -41,16 +41,17 @@ Meteor.methods({
// 3. map all fields for the card to create
const dateOfImport = new Date();
const cardToCreate = {
- title: trelloCard.name,
- description: trelloCard.desc,
- listId: list._id,
- boardId: list.boardId,
- userId: Meteor.userId(),
- sort: sortIndex,
archived: trelloCard.closed,
+ boardId: list.boardId,
// this is a default date, we'll fetch the actual one from the actions array
createdAt: dateOfImport,
dateLastActivity: dateOfImport,
+ description: trelloCard.desc,
+ listId: list._id,
+ sort: sortIndex,
+ title: trelloCard.name,
+ // XXX use the original user?
+ userId: Meteor.userId(),
};
// 4. find actual creation date
@@ -84,7 +85,20 @@ Meteor.methods({
// 6. insert new card into list
const cardId = Cards.direct.insert(cardToCreate);
- // XXX then add import activity
+ Activities.direct.insert({
+ activityType: 'importCard',
+ boardId: cardToCreate.boardId,
+ cardId: cardId,
+ createdAt: dateOfImport,
+ listId: cardToCreate.listId,
+ source: {
+ id: trelloCard.id,
+ system: 'Trello',
+ url: trelloCard.url,
+ },
+ // we attribute the import to current user, not the one from the original card
+ userId: Meteor.userId(),
+ });
// 7. parse actions and add comments
trelloCard.actions.forEach((currentAction) => {
@@ -94,6 +108,7 @@ Meteor.methods({
cardId: cardId,
createdAt: currentAction.date,
text: currentAction.data.text,
+ // XXX use the original comment user instead
userId: Meteor.userId(),
};
const commentId = CardComments.direct.insert(commentToCreate);
@@ -106,7 +121,6 @@ Meteor.methods({
userId: commentToCreate.userId,
});
}
- // XXX add other type of activities?
});
return cardId;
},