From 4ee88e026e86ab26757d46c9dadffa5005a7740f Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Thu, 19 Sep 2019 15:16:48 -0400 Subject: Buxfixed: if username contains space, it will cause @ commment failed to send out email and other --- models/activities.js | 46 ++++++++++++++++++++++++++-------------------- 1 file changed, 26 insertions(+), 20 deletions(-) (limited to 'models') diff --git a/models/activities.js b/models/activities.js index dcabfbc2..a9c9768f 100644 --- a/models/activities.js +++ b/models/activities.js @@ -180,28 +180,34 @@ if (Meteor.isServer) { const comment = activity.comment(); params.comment = comment.text; if (board) { - const atUser = /(?:^|>|\b|\s)@(\S+?)(?:\s|$|<|\b)/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 atUser = - Users.findOne(username) || Users.findOne({ username }); - if (atUser && atUser._id) { - const uid = atUser._id; - params.atUsername = username; - params.atEmails = atUser.emails; - if (board.hasMember(uid)) { - title = 'act-atUserComment'; - watchers = _.union(watchers, [uid]); - } - } + const knownUsers = board.members.map(member => { + const u = Users.findOne(member.userId); + if (u) { + member.username = u.username; + member.emails = u.emails; } + return member; + }); + const mentionRegex = /\B@(?:(?:"([\w.\s]*)")|([\w.]+))/gi; // including space in username + let currentMention; + while ((currentMention = mentionRegex.exec(comment)) !== null) { + /*eslint no-unused-vars: ["error", { "varsIgnorePattern": "[iI]gnored" }]*/ + const [ignored, quoteduser, simple] = currentMention; + const username = quoteduser || simple; + if (username === params.user) { + // ignore commenter mention himself? + continue; + } + const atUser = _.findWhere(knownUsers, { username }); + if (!atUser) { + continue; + } + const uid = atUser.userId; + params.atUsername = username; + params.atEmails = atUser.emails; + title = 'act-atUserComment'; + watchers = _.union(watchers, [uid]); } } params.commentId = comment._id; -- cgit v1.2.3-1-g7c22 From a37723f8a48277a152e4ef1fa2a42e6bb986b3a9 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Sat, 21 Sep 2019 15:32:21 -0400 Subject: Fixing method in users.js didn't have check userId --- models/users.js | 1 + 1 file changed, 1 insertion(+) (limited to 'models') diff --git a/models/users.js b/models/users.js index ee53c7ab..9147322c 100644 --- a/models/users.js +++ b/models/users.js @@ -541,6 +541,7 @@ Users.mutations({ Meteor.methods({ setUsername(username, userId) { check(username, String); + check(userId, String); const nUsersWithUsername = Users.find({ username }).count(); if (nUsersWithUsername > 0) { throw new Meteor.Error('username-already-taken'); -- cgit v1.2.3-1-g7c22 From 8d7714760c0e532d1f3d17d451dd91ba74e966e8 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Wed, 25 Sep 2019 11:26:46 -0400 Subject: BUG FIX: archived cards still sent out notification --- models/cards.js | 1 + 1 file changed, 1 insertion(+) (limited to 'models') diff --git a/models/cards.js b/models/cards.js index 1414f6d7..d30baaf1 100644 --- a/models/cards.js +++ b/models/cards.js @@ -1558,6 +1558,7 @@ function cardRemover(userId, doc) { const findDueCards = days => { const seekDue = ($from, $to, activityType) => { Cards.find({ + archived: false, dueAt: { $gte: $from, $lt: $to }, }).forEach(card => { const username = Users.findOne(card.userId).username; -- cgit v1.2.3-1-g7c22 From d5cff1ec48bf9ab13a32576e7495ae54c3d2c0f7 Mon Sep 17 00:00:00 2001 From: "Sam X. Chen" Date: Wed, 25 Sep 2019 11:48:20 -0400 Subject: Add feature: differentiating new due time and modified due time --- models/activities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'models') diff --git a/models/activities.js b/models/activities.js index a9c9768f..cb1dddaf 100644 --- a/models/activities.js +++ b/models/activities.js @@ -242,8 +242,8 @@ if (Meteor.isServer) { (!activity.timeKey || activity.timeKey === 'dueAt') && activity.timeValue ) { - // due time reminder - title = 'act-withDue'; + // due time reminder, if it doesn't have old value, it's a brand new set, need some differentiation + title = activity.timeOldValue ? 'act-withDue' : 'act-newDue'; } ['timeValue', 'timeOldValue'].forEach(key => { // copy time related keys & values to params -- cgit v1.2.3-1-g7c22