mirror of
https://github.com/wekan/wekan.git
synced 2025-12-18 00:10:13 +01:00
adds handles to notifiy board or card members
This commit is contained in:
parent
977821d293
commit
547d82fe57
2 changed files with 33 additions and 11 deletions
|
|
@ -1,3 +1,9 @@
|
||||||
|
const specialHandles = [
|
||||||
|
{userId: 'board_members', username: 'board_members'},
|
||||||
|
{userId: 'card_members', username: 'card_members'}
|
||||||
|
];
|
||||||
|
const specialHandleNames = specialHandles.map(m => m.username);
|
||||||
|
|
||||||
Template.editor.onRendered(() => {
|
Template.editor.onRendered(() => {
|
||||||
const textareaSelector = 'textarea';
|
const textareaSelector = 'textarea';
|
||||||
const mentions = [
|
const mentions = [
|
||||||
|
|
@ -7,13 +13,14 @@ Template.editor.onRendered(() => {
|
||||||
search(term, callback) {
|
search(term, callback) {
|
||||||
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
const currentBoard = Boards.findOne(Session.get('currentBoard'));
|
||||||
callback(
|
callback(
|
||||||
|
_.union(
|
||||||
currentBoard
|
currentBoard
|
||||||
.activeMembers()
|
.activeMembers()
|
||||||
.map(member => {
|
.map(member => {
|
||||||
const username = Users.findOne(member.userId).username;
|
const username = Users.findOne(member.userId).username;
|
||||||
return username.includes(term) ? username : null;
|
return username.includes(term) ? username : null;
|
||||||
})
|
})
|
||||||
.filter(Boolean),
|
.filter(Boolean), [...specialHandleNames])
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
template(value) {
|
template(value) {
|
||||||
|
|
@ -323,13 +330,13 @@ Blaze.Template.registerHelper(
|
||||||
return HTML.Raw(
|
return HTML.Raw(
|
||||||
DOMPurify.sanitize(content, { ALLOW_UNKNOWN_PROTOCOLS: true }),
|
DOMPurify.sanitize(content, { ALLOW_UNKNOWN_PROTOCOLS: true }),
|
||||||
);
|
);
|
||||||
const knowedUsers = currentBoard.members.map(member => {
|
const knowedUsers = _.union(currentBoard.members.map(member => {
|
||||||
const u = Users.findOne(member.userId);
|
const u = Users.findOne(member.userId);
|
||||||
if (u) {
|
if (u) {
|
||||||
member.username = u.username;
|
member.username = u.username;
|
||||||
}
|
}
|
||||||
return member;
|
return member;
|
||||||
});
|
}), [...specialHandles]);
|
||||||
const mentionRegex = /\B@([\w.]*)/gi;
|
const mentionRegex = /\B@([\w.]*)/gi;
|
||||||
|
|
||||||
let currentMention;
|
let currentMention;
|
||||||
|
|
|
||||||
|
|
@ -210,15 +210,30 @@ if (Meteor.isServer) {
|
||||||
// ignore commenter mention himself?
|
// ignore commenter mention himself?
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const atUser = _.findWhere(knownUsers, { username });
|
|
||||||
if (!atUser) {
|
if (activity.boardId && username === 'board_members') {
|
||||||
continue;
|
// mentions all board members
|
||||||
|
const knownUids = knownUsers.map(u => u.userId);
|
||||||
|
watchers = _.union(watchers, [...knownUids]);
|
||||||
|
title = 'act-atUserComment';
|
||||||
|
} else if (activity.cardId && username === 'card_members') {
|
||||||
|
// mentions all card members if assigned
|
||||||
|
const card = activity.card();
|
||||||
|
watchers = _.union(watchers, [...card.members]);
|
||||||
|
title = 'act-atUserComment';
|
||||||
|
} else {
|
||||||
|
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]);
|
||||||
}
|
}
|
||||||
const uid = atUser.userId;
|
|
||||||
params.atUsername = username;
|
|
||||||
params.atEmails = atUser.emails;
|
|
||||||
title = 'act-atUserComment';
|
|
||||||
watchers = _.union(watchers, [uid]);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
params.commentId = comment._id;
|
params.commentId = comment._id;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue