mirror of
https://github.com/zulip/zulip.git
synced 2025-11-12 18:06:44 +00:00
compose: Automatically change @ mentions to silent mentions in 1:1 DMs.
It is common for users in other chat tools to start off a direct message with @ mentioning the addressee. However, this results in potentially unexpected behavior in Zulip, where the message is highlighted and shows up in @ mentions in addition to DMs. We want to prevent this behaviour by automatically changing the @ mentions to silent @ mentions for the user. These changes only apply to 1:1 DMs and not group chats. Fixes: #17998.
This commit is contained in:
@@ -691,3 +691,22 @@ export function validate(scheduling_message) {
|
||||
}
|
||||
return validate_stream_message(scheduling_message);
|
||||
}
|
||||
|
||||
export function convert_mentions_to_silent_in_direct_messages(mention_text, full_name, user_id) {
|
||||
if (compose_state.get_message_type() !== "private") {
|
||||
return mention_text;
|
||||
}
|
||||
|
||||
const recipient_user_id = compose_pm_pill.get_user_ids();
|
||||
if (recipient_user_id.toString() !== user_id.toString()) {
|
||||
return mention_text;
|
||||
}
|
||||
|
||||
const mention_str = people.get_mention_syntax(full_name, user_id, false);
|
||||
const silent_mention_str = people.get_mention_syntax(full_name, user_id, true);
|
||||
mention_text = mention_text.replace(mention_str, silent_mention_str);
|
||||
// also replace other mentions...
|
||||
compose_ui.replace_syntax(mention_str, silent_mention_str);
|
||||
|
||||
return mention_text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user