From 5ca09cdf096e02cfd8e6ecd61fc4cbb651703558 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Tue, 9 Jul 2019 16:47:48 -0400 Subject: Add Feature: system timelines will be showing any modification for duat startat endat receivedat, also notification to the watchers and if card is due, watchers will be notified --- server/notifications/email.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/notifications/email.js b/server/notifications/email.js index 45642c90..d198b8b5 100644 --- a/server/notifications/email.js +++ b/server/notifications/email.js @@ -7,7 +7,7 @@ Meteor.startup(() => { if (quoteParams[key]) quoteParams[key] = `"${params[key]}"`; }); ['timeValue', 'timeOldValue'].forEach(key => { - if (quoteParams[key]) quoteParams[key] = `${params[key]}`; + quoteParams[key] = quoteParams[key] ? `${params[key]}` : ''; }); const lan = user.getLanguage(); -- cgit v1.2.3-1-g7c22 From 5fd86d29ba957fb2f00d5c83a7dd1a36a79303d8 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Thu, 11 Jul 2019 14:32:39 -0400 Subject: Add Features: notifications will be sent when user is being @, or activitytype matches env var BIGENVENTS --- i18n/en.i18n.json | 3 ++- models/activities.js | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/i18n/en.i18n.json b/i18n/en.i18n.json index f555f438..6274e08a 100644 --- a/i18n/en.i18n.json +++ b/i18n/en.i18n.json @@ -721,5 +721,6 @@ "act-withDue": "__card__ due reminders [__board__]", "act-almostdue": "was reminding the current due (__timeValue__) of __card__ is approaching", "act-pastdue": "was reminding the current due (__timeValue__) of __card__ is past", - "act-duenow": "was reminding the current due (__timeValue__) of __card__ is now" + "act-duenow": "was reminding the current due (__timeValue__) of __card__ is now", + "act-atUserComment": "You were mentioned in [__board__] __card__" } diff --git a/models/activities.js b/models/activities.js index feda36e5..168effd0 100644 --- a/models/activities.js +++ b/models/activities.js @@ -171,6 +171,26 @@ if (Meteor.isServer) { if (activity.commentId) { const comment = activity.comment(); params.comment = comment.text; + if (board) { + const atUser = /(?:^|\s+)@(\S+)(?:\s+|$)/g; + const comment = params.comment; + if (comment.match(atUser)) { + const commenter = params.user; + while (atUser.exec(comment)) { + const username = RegExp.$1; + if (commenter === username) { + // it's person at himself, ignore it? + continue; + } + const user = Users.findOne(username) || Users.findOne({ username }); + const uid = user && user._id; + if (board.hasMember(uid)) { + title = 'act-atUserComment'; + watchers = _.union(watchers, [uid]); + } + } + } + } params.commentId = comment._id; } if (activity.attachmentId) { @@ -212,6 +232,19 @@ if (Meteor.isServer) { if (value) params[key] = value; }); if (board) { + const BIGEVENTS = process.env.BIGEVENTS_PATTERN || 'due'; // if environment BIGEVENTS_PATTERN is set or default, any activityType matching it is important + try { + const atype = activity.activityType; + if (new RegExp(BIGEVENTS).exec(atype)) { + watchers = _.union( + watchers, + board.activeMembers().map(member => member.userId), + ); // notify all active members for important events system defined or default to all activity related to due date + } + } catch (e) { + // passed env var BIGEVENTS_PATTERN is not a valid regex + } + const watchingUsers = _.pluck( _.where(board.watchers, { level: 'watching' }), 'userId', -- cgit v1.2.3-1-g7c22