diff options
author | Lauri Ojansivu <x@xet7.org> | 2017-09-02 16:05:14 +0300 |
---|---|---|
committer | Lauri Ojansivu <x@xet7.org> | 2017-09-02 16:05:14 +0300 |
commit | 17cf8ded07e77726d6a6d037b446da50ef734095 (patch) | |
tree | 38a5fd5d88633a2cdaab35339f5c39156d2de3f8 /models/wekanCreator.js | |
parent | d4537af3b4a3072196309ddaa0679dc935f3c46c (diff) | |
parent | 181af6f2508405c0459197445f3b02f8368cb490 (diff) | |
download | wekan-17cf8ded07e77726d6a6d037b446da50ef734095.tar.gz wekan-17cf8ded07e77726d6a6d037b446da50ef734095.tar.bz2 wekan-17cf8ded07e77726d6a6d037b446da50ef734095.zip |
Merge branch 'feature/manual-attachments-activities' of https://github.com/GhassenRjab/wekan into GhassenRjab-feature/manual-attachments-activities
Diffstat (limited to 'models/wekanCreator.js')
-rw-r--r-- | models/wekanCreator.js | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/models/wekanCreator.js b/models/wekanCreator.js index 1a02339a..9c7f50ec 100644 --- a/models/wekanCreator.js +++ b/models/wekanCreator.js @@ -307,18 +307,23 @@ export class WekanCreator { // - HEAD returns null, which causes exception down the line // - the template then tries to display the url to the attachment which causes other errors // 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) { if (att.url) { file.attachData(att.url, function (error) { file.boardId = boardId; file.cardId = cardId; + file.userId = self._user(att.userId); + // The field source will only be used to prevent adding + // attachments' related activities automatically + file.source = 'import'; if (error) { throw(error); } else { const wekanAtt = Attachments.insert(file, () => { // we do nothing }); - this.attachmentIds[att._id] = wekanAtt._id; + self.attachmentIds[att._id] = wekanAtt._id; // if(wekanCoverId === att._id) { Cards.direct.update(cardId, { $set: {coverId: wekanAtt._id}}); @@ -330,6 +335,10 @@ export class WekanCreator { file.name(att.name); file.boardId = boardId; file.cardId = cardId; + file.userId = self._user(att.userId); + // The field source will only be used to prevent adding + // attachments' related activities automatically + file.source = 'import'; if (error) { throw(error); } else { @@ -541,24 +550,18 @@ export class WekanCreator { break; } // Attachment related activities - // TODO: We can't add activities related to adding attachments - // because when we import an attachment, an activity is - // autmatically created. We need to directly insert the attachment - // without calling the "Attachments.files.after.insert" hook first, - // then we can uncomment the code below - // case 'addAttachment': { - // console.log(this.attachmentIds); - // Activities.direct.insert({ - // userId: this._user(activity.userId), - // type: 'card', - // activityType: activity.activityType, - // attachmentId: this.attachmentIds[activity.attachmentId], - // cardId: this.cards[activity.cardId], - // boardId, - // createdAt: this._now(activity.createdAt), - // }); - // break; - // } + case 'addAttachment': { + Activities.direct.insert({ + userId: this._user(activity.userId), + type: 'card', + activityType: activity.activityType, + attachmentId: this.attachmentIds[activity.attachmentId], + cardId: this.cards[activity.cardId], + boardId, + createdAt: this._now(activity.createdAt), + }); + break; + } // Checklist related activities case 'addChecklist': { Activities.direct.insert({ |