Improve PR, adding more comments

This commit is contained in:
floatinghotpot 2016-01-06 16:59:25 +08:00
parent 9bbdacc79a
commit 39e1cc0237
3 changed files with 32 additions and 26 deletions

View file

@ -50,10 +50,10 @@ if (Meteor.isServer) {
});
Activities.after.insert((userId, doc) => {
const activity = Activities.findOne(doc._id);
const activity = Activities._transform(doc);
let participants = [];
let watchers = [];
let title = 'Wekan Notification';
let title = 'act-activity-notify';
let board = null;
const description = `act-${activity.activityType}`;
const params = {
@ -101,20 +101,20 @@ if (Meteor.isServer) {
params.attachment = attachment._id;
}
if (board) {
const boardWatching = _.pluck(_.where(board.watchers, {level: 'watching'}), 'userId');
const boardTracking = _.pluck(_.where(board.watchers, {level: 'tracking'}), 'userId');
const boardMuted = _.pluck(_.where(board.watchers, {level: 'muted'}), 'userId');
const watchingUsers = _.pluck(_.where(board.watchers, {level: 'watching'}), 'userId');
const trackingUsers = _.pluck(_.where(board.watchers, {level: 'tracking'}), 'userId');
const mutedUsers = _.pluck(_.where(board.watchers, {level: 'muted'}), 'userId');
switch(board.getWatchDefault()) {
case 'muted':
participants = _.intersection(participants, boardTracking);
watchers = _.intersection(watchers, boardTracking);
participants = _.intersection(participants, trackingUsers);
watchers = _.intersection(watchers, trackingUsers);
break;
case 'tracking':
participants = _.difference(participants, boardMuted);
watchers = _.difference(watchers, boardMuted);
participants = _.difference(participants, mutedUsers);
watchers = _.difference(watchers, mutedUsers);
break;
}
watchers = _.union(watchers, boardWatching || []);
watchers = _.union(watchers, watchingUsers || []);
}
Notifications.getUsers(participants, watchers).forEach((user) => {

View file

@ -57,9 +57,9 @@ Users.helpers({
return _.contains(notifications, activityId);
},
getEmailCache() {
const {emailCache = []} = this.profile;
return emailCache;
getEmailBuffer() {
const {emailBuffer = []} = this.profile;
return emailBuffer;
},
getInitials() {
@ -153,18 +153,18 @@ Users.mutations({
};
},
addEmailCache(text) {
addEmailBuffer(text) {
return {
$addToSet: {
'profile.emailCache': text,
'profile.emailBuffer': text,
},
};
},
clearEmailCache() {
clearEmailBuffer() {
return {
$set: {
'profile.emailCache': [],
'profile.emailBuffer': [],
},
};
},