summaryrefslogtreecommitdiffstats
path: root/models/activities.js
diff options
context:
space:
mode:
authorSam X. Chen <sam.xi.chen@gmail.com>2019-07-11 14:32:39 -0400
committerSam X. Chen <sam.xi.chen@gmail.com>2019-07-11 14:32:39 -0400
commit5fd86d29ba957fb2f00d5c83a7dd1a36a79303d8 (patch)
treed1c91744cfbe0b218b24b1d75ce56df12294f717 /models/activities.js
parentf2a0ae0a2c115a1cfdc3c6153ca80fd03df12ba7 (diff)
downloadwekan-5fd86d29ba957fb2f00d5c83a7dd1a36a79303d8.tar.gz
wekan-5fd86d29ba957fb2f00d5c83a7dd1a36a79303d8.tar.bz2
wekan-5fd86d29ba957fb2f00d5c83a7dd1a36a79303d8.zip
Add Features: notifications will be sent when user is being @, or activitytype matches env var BIGENVENTS
Diffstat (limited to 'models/activities.js')
-rw-r--r--models/activities.js33
1 files changed, 33 insertions, 0 deletions
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',