diff --git a/keyserver/src/push/send.js b/keyserver/src/push/send.js --- a/keyserver/src/push/send.js +++ b/keyserver/src/push/send.js @@ -10,6 +10,7 @@ import uuidv4 from 'uuid/v4.js'; import { oldValidUsernameRegex } from 'lib/shared/account-utils.js'; +import { isMentioned } from 'lib/shared/mention-utils.js'; import { createMessageInfo, sortMessageInfoList, @@ -135,7 +136,7 @@ threadInfo.currentUser.role && oldValidUsernameRegex.test(username) && firstNewMessageInfo.type === messageTypes.TEXT && - new RegExp(`\\B@${username}\\b`, 'i').test(firstNewMessageInfo.text); + isMentioned(username, firstNewMessageInfo.text); if (!updateBadge && !displayBanner && !userWasMentioned) { continue; } diff --git a/lib/shared/mention-utils.js b/lib/shared/mention-utils.js --- a/lib/shared/mention-utils.js +++ b/lib/shared/mention-utils.js @@ -15,6 +15,10 @@ +end: number, }; +function isMentioned(username: string, text: string): boolean { + return new RegExp(`\\B@${username}\\b`, 'i').test(text); +} + function getTypeaheadRegexMatches( text: string, selection: Selection, @@ -69,6 +73,7 @@ } export { + isMentioned, getTypeaheadUserSuggestions, getNewTextAndSelection, getTypeaheadRegexMatches,