diff --git a/apps/meteor/app/mentions/server/Mentions.ts b/apps/meteor/app/mentions/server/Mentions.ts index 779af2087932f..f6d40840b6488 100644 --- a/apps/meteor/app/mentions/server/Mentions.ts +++ b/apps/meteor/app/mentions/server/Mentions.ts @@ -54,7 +54,7 @@ export class MentionsServer extends MentionsParser { const userMentions = []; for await (const m of mentions) { - const mention = m.trim().substr(1); + const mention = m.includes(':') ? m.trim() : m.trim().substring(1); if (mention !== 'all' && mention !== 'here') { userMentions.push(mention); continue; @@ -79,7 +79,7 @@ export class MentionsServer extends MentionsParser { isE2EEMessage(message) && e2eMentions?.e2eChannelMentions && e2eMentions?.e2eChannelMentions.length > 0 ? e2eMentions?.e2eChannelMentions : this.getChannelMentions(msg); - return this.getChannels(channels.map((c) => c.trim().substr(1))); + return this.getChannels(channels.map((c) => c.trim().substring(1))); } async execute(message: IMessage) { diff --git a/apps/meteor/client/components/GazzodownText.tsx b/apps/meteor/client/components/GazzodownText.tsx index 26703ab094093..dc3f25ba96a4e 100644 --- a/apps/meteor/client/components/GazzodownText.tsx +++ b/apps/meteor/client/components/GazzodownText.tsx @@ -66,7 +66,12 @@ const GazzodownText = ({ mentions, channels, searchText, children }: GazzodownTe return undefined; } - const filterUser = ({ username, type }: UserMention) => (!type || type === 'user') && username === mention; + const normalizedMention = mention.startsWith('@') ? mention.substring(1) : mention; + const filterUser = ({ username, type }: UserMention) => { + if (!username || type === 'team') return false; + const normalizedUsername = username.startsWith('@') ? username.substring(1) : username; + return normalizedUsername === normalizedMention; + }; const filterTeam = ({ name, type }: UserMention) => type === 'team' && name === mention; return mentions?.find((mention) => filterUser(mention) || filterTeam(mention)); diff --git a/apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx b/apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx index d656c607f3011..b86926bd1b0ad 100644 --- a/apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx +++ b/apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx @@ -153,7 +153,7 @@ const ComposerPopupProvider = ({ children, room }: ComposerPopupProviderProps) = }; }); }, - getValue: (item) => item.username, + getValue: (item) => (item.username.startsWith('@') ? item.username.substring(1) : item.username), renderItem: ({ item }) => , }), createMessageBoxPopupConfig({