Skip to content

Commit a6fae0b

Browse files
committed
fix federated user mentions being shown as plain text on RC side
1 parent 0f4dfef commit a6fae0b

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

apps/meteor/app/mentions/server/Mentions.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ export class MentionsServer extends MentionsParser {
5454
const userMentions = [];
5555

5656
for await (const m of mentions) {
57-
const mention = m.trim().substr(1);
57+
const mention = m.includes(':') ? m.trim() : m.trim().substring(1);
5858
if (mention !== 'all' && mention !== 'here') {
5959
userMentions.push(mention);
6060
continue;
@@ -79,7 +79,7 @@ export class MentionsServer extends MentionsParser {
7979
isE2EEMessage(message) && e2eMentions?.e2eChannelMentions && e2eMentions?.e2eChannelMentions.length > 0
8080
? e2eMentions?.e2eChannelMentions
8181
: this.getChannelMentions(msg);
82-
return this.getChannels(channels.map((c) => c.trim().substr(1)));
82+
return this.getChannels(channels.map((c) => c.trim().substring(1)));
8383
}
8484

8585
async execute(message: IMessage) {

apps/meteor/client/components/GazzodownText.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,12 @@ const GazzodownText = ({ mentions, channels, searchText, children }: GazzodownTe
6666
return undefined;
6767
}
6868

69-
const filterUser = ({ username, type }: UserMention) => (!type || type === 'user') && username === mention;
69+
const normalizedMention = mention.startsWith('@') ? mention.substring(1) : mention;
70+
const filterUser = ({ username, type }: UserMention) => {
71+
if (!username || type === 'team') return false;
72+
const normalizedUsername = username.startsWith('@') ? username.substring(1) : username;
73+
return normalizedUsername === normalizedMention;
74+
};
7075
const filterTeam = ({ name, type }: UserMention) => type === 'team' && name === mention;
7176

7277
return mentions?.find((mention) => filterUser(mention) || filterTeam(mention));

apps/meteor/client/views/room/providers/ComposerPopupProvider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ const ComposerPopupProvider = ({ children, room }: ComposerPopupProviderProps) =
153153
};
154154
});
155155
},
156-
getValue: (item) => item.username,
156+
getValue: (item) => (item.username.startsWith('@') ? item.username.substring(1) : item.username),
157157
renderItem: ({ item }) => <ComposerBoxPopupUser {...item} />,
158158
}),
159159
createMessageBoxPopupConfig<ComposerBoxPopupRoomProps>({

0 commit comments

Comments
 (0)