summaryrefslogtreecommitdiffstats
path: root/models/attachments.js
diff options
context:
space:
mode:
authorGhassen Rjab <rjab.ghassen@gmail.com>2017-09-02 07:17:42 +0100
committerGhassen Rjab <rjab.ghassen@gmail.com>2017-09-02 07:17:42 +0100
commit6ff0cf91e2fe6fd0e777225eb7afb3b37ac313e7 (patch)
treeaadf4114a96c7954a9e78060e1708e07787e56c6 /models/attachments.js
parent4ad4c6ea2274919ced917e541120ad50c7512b80 (diff)
downloadwekan-6ff0cf91e2fe6fd0e777225eb7afb3b37ac313e7.tar.gz
wekan-6ff0cf91e2fe6fd0e777225eb7afb3b37ac313e7.tar.bz2
wekan-6ff0cf91e2fe6fd0e777225eb7afb3b37ac313e7.zip
Add source field to imported attachments
We use this field to prevent adding attachments' related activities automatically only. Then this field will be removed.
Diffstat (limited to 'models/attachments.js')
-rw-r--r--models/attachments.js25
1 files changed, 17 insertions, 8 deletions
diff --git a/models/attachments.js b/models/attachments.js
index 3e5d4437..40adda49 100644
--- a/models/attachments.js
+++ b/models/attachments.js
@@ -55,14 +55,23 @@ if (Meteor.isServer) {
if (Meteor.isServer) {
Attachments.files.after.insert((userId, doc) => {
- Activities.insert({
- userId,
- type: 'card',
- activityType: 'addAttachment',
- attachmentId: doc._id,
- boardId: doc.boardId,
- cardId: doc.cardId,
- });
+ // If the attachment doesn't have a source field
+ // or its source is different than import
+ if (!doc.source || doc.source !== 'import') {
+ // Add activity about adding the attachment
+ Activities.insert({
+ userId,
+ type: 'card',
+ activityType: 'addAttachment',
+ attachmentId: doc._id,
+ boardId: doc.boardId,
+ cardId: doc.cardId,
+ });
+ } else {
+ // Don't add activity about adding the attachment as the activity
+ // be imported and delete source field
+ Attachments.update( {_id: doc._id} , {$unset: { source : "" } } );
+ }
});
Attachments.files.after.remove((userId, doc) => {