diff options
author | Maxime Quandalle <maxime@quandalle.com> | 2015-09-03 23:12:46 +0200 |
---|---|---|
committer | Maxime Quandalle <maxime@quandalle.com> | 2015-09-03 23:12:46 +0200 |
commit | b3851817ecd59b039f2c2228d08a1c6fd8e60d60 (patch) | |
tree | 82a50f69788d5c20632f3ec9c7d3e136502b93b4 /collections/attachments.js | |
parent | 039cfe7edf8faf901069a94b3ca9b66f7973b26a (diff) | |
download | wekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.tar.gz wekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.tar.bz2 wekan-b3851817ecd59b039f2c2228d08a1c6fd8e60d60.zip |
Enforce a consistent ES6 coding style
Replace the old (and broken) jshint + jscsrc by eslint and configure
it to support some of the ES6 features.
The command `eslint` currently has one error which is a bug that was
discovered by its static analysis and should be fixed (usage of a
dead object).
Diffstat (limited to 'collections/attachments.js')
-rw-r--r-- | collections/attachments.js | 36 |
1 files changed, 18 insertions, 18 deletions
diff --git a/collections/attachments.js b/collections/attachments.js index c8fe6b18..8ef0fef0 100644 --- a/collections/attachments.js +++ b/collections/attachments.js @@ -3,19 +3,19 @@ Attachments = new FS.Collection('attachments', { // XXX Add a new store for cover thumbnails so we don't load big images in // the general board view - new FS.Store.GridFS('attachments') - ] + new FS.Store.GridFS('attachments'), + ], }); if (Meteor.isServer) { Attachments.allow({ - insert: function(userId, doc) { + insert(userId, doc) { return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); }, - update: function(userId, doc) { + update(userId, doc) { return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); }, - remove: function(userId, doc) { + remove(userId, doc) { return allowIsBoardMember(userId, Boards.findOne(doc.boardId)); }, // We authorize the attachment download either: @@ -26,24 +26,24 @@ if (Meteor.isServer) { // // https://github.com/CollectionFS/Meteor-CollectionFS/issues/449 // - download: function(userId, doc) { - var query = { + download(userId, doc) { + const query = { $or: [ { 'members.userId': userId }, - { permission: 'public' } - ] + { permission: 'public' }, + ], }; - return !! Boards.findOne(doc.boardId, query); + return Boolean(Boards.findOne(doc.boardId, query)); }, - fetch: ['boardId'] + fetch: ['boardId'], }); } // XXX Enforce a schema for the Attachments CollectionFS -Attachments.files.before.insert(function(userId, doc) { - var file = new FS.File(doc); +Attachments.files.before.insert((userId, doc) => { + const file = new FS.File(doc); doc.userId = userId; // If the uploaded document is not an image we need to enforce browser @@ -54,26 +54,26 @@ Attachments.files.before.insert(function(userId, doc) { // See https://github.com/libreboard/libreboard/issues/99 // XXX Should we use `beforeWrite` option of CollectionFS instead of // collection-hooks? - if (! file.isImage()) { + if (!file.isImage()) { file.original.type = 'application/octet-stream'; } }); if (Meteor.isServer) { - Attachments.files.after.insert(function(userId, doc) { + Attachments.files.after.insert((userId, doc) => { Activities.insert({ + userId, type: 'card', activityType: 'addAttachment', attachmentId: doc._id, boardId: doc.boardId, cardId: doc.cardId, - userId: userId }); }); - Attachments.files.after.remove(function(userId, doc) { + Attachments.files.after.remove((userId, doc) => { Activities.remove({ - attachmentId: doc._id + attachmentId: doc._id, }); }); } |