mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 15:30:13 +01:00
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).
51 lines
1.4 KiB
JavaScript
51 lines
1.4 KiB
JavaScript
// Activities don't need a schema because they are always set from the a trusted
|
|
// environment - the server - and there is no risk that a user change the logic
|
|
// we use with this collection. Moreover using a schema for this collection
|
|
// would be difficult (different activities have different fields) and wouldn't
|
|
// bring any direct advantage.
|
|
//
|
|
// XXX The activities API is not so nice and need some functionalities. For
|
|
// instance if a user archive a card, and un-archive it a few seconds later we
|
|
// should remove both activities assuming it was an error the user decided to
|
|
// revert.
|
|
Activities = new Mongo.Collection('activities');
|
|
|
|
Activities.helpers({
|
|
board() {
|
|
return Boards.findOne(this.boardId);
|
|
},
|
|
user() {
|
|
return Users.findOne(this.userId);
|
|
},
|
|
member() {
|
|
return Users.findOne(this.memberId);
|
|
},
|
|
list() {
|
|
return Lists.findOne(this.listId);
|
|
},
|
|
oldList() {
|
|
return Lists.findOne(this.oldListId);
|
|
},
|
|
card() {
|
|
return Cards.findOne(this.cardId);
|
|
},
|
|
comment() {
|
|
return CardComments.findOne(this.commentId);
|
|
},
|
|
attachment() {
|
|
return Attachments.findOne(this.attachmentId);
|
|
},
|
|
});
|
|
|
|
Activities.before.insert((userId, doc) => {
|
|
doc.createdAt = new Date();
|
|
});
|
|
|
|
// For efficiency create an index on the date of creation.
|
|
if (Meteor.isServer) {
|
|
Meteor.startup(() => {
|
|
Activities._collection._ensureIndex({
|
|
createdAt: -1,
|
|
});
|
|
});
|
|
}
|