mirror of https://github.com/zulip/zulip.git
topic_mentions: Rename wildcard_mentioned to stream_wildcard_mentioned.
Rename the existing 'wildcard_mentioned' flag to 'stream_wildcard_mentioned'. The 'wildcard_mentioned' flag is deprecated and exists for backwards compatibility. We have two separate flags for stream and topic wildcard mentions, i.e., 'stream_wildcard_mentioned' and 'topic_wildcard_mentioned', respectively. * stream wildcard mentions: `@all`, `@everyone`, and `@stream` * topic wildcard mentions: `@topic` The `wildcard_mentioned` flag is included in the events and API response if either `stream_wildcard_mentioned` or `topic_wildcard_mentioned` is set.
This commit is contained in:
parent
24fa361f40
commit
c597de6a1d
|
@ -20,6 +20,13 @@ format used by the Zulip server that they are interacting with.
|
|||
|
||||
## Changes in Zulip 8.0
|
||||
|
||||
**Feature level 224**
|
||||
|
||||
* [`GET /events`](/api/get-events), [`GET /messages`](/api/get-messages),
|
||||
[`GET /messages/{message_id}`](/api/get-message): The `wildcard_mentioned`
|
||||
flag was deprecated, replaced with `stream_wildcard_mentioned` and
|
||||
`topic_wildcard_mentioned`, but it is still available for backwards compatibility.
|
||||
|
||||
**Feature level 223**
|
||||
|
||||
* `POST /users/me/apns_device_token`:
|
||||
|
|
|
@ -33,7 +33,7 @@ DESKTOP_WARNING_VERSION = "5.9.3"
|
|||
# Changes should be accompanied by documentation explaining what the
|
||||
# new level means in api_docs/changelog.md, as well as "**Changes**"
|
||||
# entries in the endpoint's documentation in `zulip.yaml`.
|
||||
API_FEATURE_LEVEL = 223
|
||||
API_FEATURE_LEVEL = 224
|
||||
|
||||
# Bump the minor PROVISION_VERSION to indicate that folks should provision
|
||||
# only when going from an old version of the code to a newer version. Bump
|
||||
|
|
|
@ -104,7 +104,8 @@ function parse_with_options({raw_content, helper_config, options}) {
|
|||
|
||||
let mentioned = false;
|
||||
let mentioned_group = false;
|
||||
let mentioned_wildcard = false;
|
||||
let mentioned_stream_wildcard = false;
|
||||
let mentioned_topic_wildcard = false;
|
||||
|
||||
const marked_options = {
|
||||
...options,
|
||||
|
@ -117,7 +118,7 @@ function parse_with_options({raw_content, helper_config, options}) {
|
|||
display_text = mention;
|
||||
} else {
|
||||
// Stream Wildcard mention
|
||||
mentioned_wildcard = true;
|
||||
mentioned_stream_wildcard = true;
|
||||
display_text = "@" + mention;
|
||||
classes = "user-mention";
|
||||
}
|
||||
|
@ -132,7 +133,7 @@ function parse_with_options({raw_content, helper_config, options}) {
|
|||
display_text = mention;
|
||||
} else {
|
||||
// Topic Wildcard mention
|
||||
mentioned_wildcard = true;
|
||||
mentioned_topic_wildcard = true;
|
||||
display_text = "@" + mention;
|
||||
classes = "topic-mention";
|
||||
}
|
||||
|
@ -271,7 +272,8 @@ function parse_with_options({raw_content, helper_config, options}) {
|
|||
// flash of mention styling.
|
||||
mentioned = false;
|
||||
mentioned_group = false;
|
||||
mentioned_wildcard = false;
|
||||
mentioned_stream_wildcard = false;
|
||||
mentioned_topic_wildcard = false;
|
||||
return quote;
|
||||
},
|
||||
};
|
||||
|
@ -286,8 +288,11 @@ function parse_with_options({raw_content, helper_config, options}) {
|
|||
if (mentioned || mentioned_group) {
|
||||
flags.push("mentioned");
|
||||
}
|
||||
if (mentioned_wildcard) {
|
||||
flags.push("wildcard_mentioned");
|
||||
if (mentioned_stream_wildcard) {
|
||||
flags.push("stream_wildcard_mentioned");
|
||||
}
|
||||
if (mentioned_topic_wildcard) {
|
||||
flags.push("topic_wildcard_mentioned");
|
||||
}
|
||||
|
||||
return {content, flags};
|
||||
|
|
|
@ -958,7 +958,8 @@ export function save_message_row_edit($row) {
|
|||
changed = old_content !== new_content;
|
||||
}
|
||||
|
||||
const already_has_wildcard_mention = message.wildcard_mentioned;
|
||||
const already_has_wildcard_mention =
|
||||
message.stream_wildcard_mentioned || message.topic_wildcard_mentioned;
|
||||
if (!already_has_wildcard_mention) {
|
||||
const wildcard_mention = util.find_wildcard_mentions(new_content);
|
||||
const is_stream_message_mentions_valid = compose_validate.validate_stream_message_mentions({
|
||||
|
|
|
@ -68,9 +68,13 @@ export function set_message_booleans(message) {
|
|||
message.unread = !convert_flag("read");
|
||||
message.historical = convert_flag("historical");
|
||||
message.starred = convert_flag("starred");
|
||||
message.mentioned = convert_flag("mentioned") || convert_flag("wildcard_mentioned");
|
||||
message.mentioned =
|
||||
convert_flag("mentioned") ||
|
||||
convert_flag("stream_wildcard_mentioned") ||
|
||||
convert_flag("topic_wildcard_mentioned");
|
||||
message.mentioned_me_directly = convert_flag("mentioned");
|
||||
message.wildcard_mentioned = convert_flag("wildcard_mentioned");
|
||||
message.stream_wildcard_mentioned = convert_flag("stream_wildcard_mentioned");
|
||||
message.topic_wildcard_mentioned = convert_flag("topic_wildcard_mentioned");
|
||||
message.collapsed = convert_flag("collapsed");
|
||||
message.alerted = convert_flag("has_alert_word");
|
||||
|
||||
|
@ -88,9 +92,13 @@ export function update_booleans(message, flags) {
|
|||
return flags.includes(flag_name);
|
||||
}
|
||||
|
||||
message.mentioned = convert_flag("mentioned") || convert_flag("wildcard_mentioned");
|
||||
message.mentioned =
|
||||
convert_flag("mentioned") ||
|
||||
convert_flag("stream_wildcard_mentioned") ||
|
||||
convert_flag("topic_wildcard_mentioned");
|
||||
message.mentioned_me_directly = convert_flag("mentioned");
|
||||
message.wildcard_mentioned = convert_flag("wildcard_mentioned");
|
||||
message.stream_wildcard_mentioned = convert_flag("stream_wildcard_mentioned");
|
||||
message.topic_wildcard_mentioned = convert_flag("topic_wildcard_mentioned");
|
||||
message.alerted = convert_flag("has_alert_word");
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,8 @@ export type MessageWithBooleans = (
|
|||
starred: boolean;
|
||||
mentioned: boolean;
|
||||
mentioned_me_directly: boolean;
|
||||
wildcard_mentioned: boolean;
|
||||
stream_wildcard_mentioned: boolean;
|
||||
topic_wildcard_mentioned: boolean;
|
||||
collapsed: boolean;
|
||||
alerted: boolean;
|
||||
};
|
||||
|
|
|
@ -284,7 +284,13 @@ test("message_flags", () => {
|
|||
|
||||
message = {raw_content: "@**all**"};
|
||||
markdown.apply_markdown(message);
|
||||
assert.ok(message.flags.includes("wildcard_mentioned"));
|
||||
assert.ok(message.flags.includes("stream_wildcard_mentioned"));
|
||||
assert.ok(!message.flags.includes("topic_wildcard_mentioned"));
|
||||
|
||||
message = {raw_content: "@**topic**"};
|
||||
markdown.apply_markdown(message);
|
||||
assert.ok(!message.flags.includes("stream_wildcard_mentioned"));
|
||||
assert.ok(message.flags.includes("topic_wildcard_mentioned"));
|
||||
});
|
||||
|
||||
test("marked", () => {
|
||||
|
@ -713,111 +719,129 @@ test("message_flags", () => {
|
|||
markdown.apply_markdown(message);
|
||||
assert.equal(message.is_me_message, false);
|
||||
assert.equal(message.flags.includes("mentioned"), true);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
|
||||
input = "test @**everyone**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.is_me_message, false);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @**stream**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.is_me_message, false);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @**topic**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.is_me_message, false);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), true);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @all";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @everyone";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @topic";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @any";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @alleycat.com";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @*hamletcharacters*";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), true);
|
||||
|
||||
input = "test @*backend*";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @**invalid_user**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @_**all**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "> test @**all**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @_**topic**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "> test @**topic**";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "test @_*hamletcharacters*";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
|
||||
input = "> test @*hamletcharacters*";
|
||||
message = {topic: "No links here", raw_content: input};
|
||||
markdown.apply_markdown(message);
|
||||
assert.equal(message.flags.includes("wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("stream_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("topic_wildcard_mentioned"), false);
|
||||
assert.equal(message.flags.includes("mentioned"), false);
|
||||
});
|
||||
|
||||
|
|
|
@ -131,7 +131,8 @@ run_test("update_messages", () => {
|
|||
is_stream: true,
|
||||
last_edit_timestamp: undefined,
|
||||
mentioned: false,
|
||||
wildcard_mentioned: false,
|
||||
stream_wildcard_mentioned: false,
|
||||
topic_wildcard_mentioned: false,
|
||||
mentioned_me_directly: false,
|
||||
raw_content: "**new content**",
|
||||
reactions: [],
|
||||
|
|
|
@ -182,24 +182,35 @@ test("message_booleans_parity", () => {
|
|||
assert.equal(update_message.topic, "update_booleans");
|
||||
};
|
||||
|
||||
assert_bool_match(["wildcard_mentioned"], {
|
||||
assert_bool_match(["stream_wildcard_mentioned"], {
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
wildcard_mentioned: true,
|
||||
stream_wildcard_mentioned: true,
|
||||
topic_wildcard_mentioned: false,
|
||||
alerted: false,
|
||||
});
|
||||
|
||||
assert_bool_match(["topic_wildcard_mentioned"], {
|
||||
mentioned: true,
|
||||
mentioned_me_directly: false,
|
||||
stream_wildcard_mentioned: false,
|
||||
topic_wildcard_mentioned: true,
|
||||
alerted: false,
|
||||
});
|
||||
|
||||
assert_bool_match(["mentioned"], {
|
||||
mentioned: true,
|
||||
mentioned_me_directly: true,
|
||||
wildcard_mentioned: false,
|
||||
stream_wildcard_mentioned: false,
|
||||
topic_wildcard_mentioned: false,
|
||||
alerted: false,
|
||||
});
|
||||
|
||||
assert_bool_match(["has_alert_word"], {
|
||||
mentioned: false,
|
||||
mentioned_me_directly: false,
|
||||
wildcard_mentioned: false,
|
||||
stream_wildcard_mentioned: false,
|
||||
topic_wildcard_mentioned: false,
|
||||
alerted: true,
|
||||
});
|
||||
});
|
||||
|
@ -249,28 +260,39 @@ test("update_booleans", () => {
|
|||
// First, test fields that we do actually want to update.
|
||||
message.mentioned = false;
|
||||
message.mentioned_me_directly = false;
|
||||
message.wildcard_mentioned = false;
|
||||
message.stream_wildcard_mentioned = false;
|
||||
message.topic_wildcard_mentioned = false;
|
||||
message.alerted = false;
|
||||
|
||||
let flags = ["mentioned", "has_alert_word", "read"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, true);
|
||||
assert.equal(message.mentioned_me_directly, true);
|
||||
assert.equal(message.wildcard_mentioned, false);
|
||||
assert.equal(message.stream_wildcard_mentioned, false);
|
||||
assert.equal(message.topic_wildcard_mentioned, false);
|
||||
assert.equal(message.alerted, true);
|
||||
|
||||
flags = ["wildcard_mentioned", "unread"];
|
||||
flags = ["stream_wildcard_mentioned", "unread"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, true);
|
||||
assert.equal(message.mentioned_me_directly, false);
|
||||
assert.equal(message.wildcard_mentioned, true);
|
||||
assert.equal(message.stream_wildcard_mentioned, true);
|
||||
assert.equal(message.topic_wildcard_mentioned, false);
|
||||
|
||||
flags = ["topic_wildcard_mentioned", "unread"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, true);
|
||||
assert.equal(message.mentioned_me_directly, false);
|
||||
assert.equal(message.stream_wildcard_mentioned, false);
|
||||
assert.equal(message.topic_wildcard_mentioned, true);
|
||||
|
||||
flags = ["read"];
|
||||
message_store.update_booleans(message, flags);
|
||||
assert.equal(message.mentioned, false);
|
||||
assert.equal(message.mentioned_me_directly, false);
|
||||
assert.equal(message.alerted, false);
|
||||
assert.equal(message.wildcard_mentioned, false);
|
||||
assert.equal(message.stream_wildcard_mentioned, false);
|
||||
assert.equal(message.topic_wildcard_mentioned, false);
|
||||
|
||||
// Make sure we don't muck with unread.
|
||||
message.unread = false;
|
||||
|
|
|
@ -250,7 +250,7 @@ def get_mentions_for_message_updates(message_id: int) -> Set[int]:
|
|||
.filter(
|
||||
Q(
|
||||
flags__andnz=UserMessage.flags.mentioned
|
||||
| UserMessage.flags.wildcard_mentioned
|
||||
| UserMessage.flags.stream_wildcard_mentioned
|
||||
| UserMessage.flags.topic_wildcard_mentioned
|
||||
| UserMessage.flags.group_mentioned
|
||||
)
|
||||
|
@ -287,7 +287,7 @@ def update_user_message_flags(
|
|||
update_flag(um, mentioned, UserMessage.flags.mentioned)
|
||||
|
||||
if rendering_result.mentions_stream_wildcard:
|
||||
update_flag(um, True, UserMessage.flags.wildcard_mentioned)
|
||||
update_flag(um, True, UserMessage.flags.stream_wildcard_mentioned)
|
||||
elif rendering_result.mentions_topic_wildcard:
|
||||
topic_wildcard_mentioned = um.user_profile_id in topic_participant_user_ids
|
||||
update_flag(um, topic_wildcard_mentioned, UserMessage.flags.topic_wildcard_mentioned)
|
||||
|
|
|
@ -725,7 +725,7 @@ def create_user_messages(
|
|||
|
||||
base_flags = 0
|
||||
if rendering_result.mentions_stream_wildcard:
|
||||
base_flags |= UserMessage.flags.wildcard_mentioned
|
||||
base_flags |= UserMessage.flags.stream_wildcard_mentioned
|
||||
if message.recipient.type in [Recipient.HUDDLE, Recipient.PERSONAL]:
|
||||
base_flags |= UserMessage.flags.is_private
|
||||
|
||||
|
@ -1009,6 +1009,13 @@ def do_send_messages(
|
|||
users: List[UserData] = []
|
||||
for user_id in user_list:
|
||||
flags = user_flags.get(user_id, [])
|
||||
# TODO/compatibility: The `wildcard_mentioned` flag was deprecated in favor of
|
||||
# the `stream_wildcard_mentioned` and `topic_wildcard_mentioned` flags. The
|
||||
# `wildcard_mentioned` flag exists for backwards-compatibility with older
|
||||
# clients. Remove this when we no longer support legacy clients that have not
|
||||
# been updated to access `stream_wildcard_mentioned`.
|
||||
if "stream_wildcard_mentioned" in flags or "topic_wildcard_mentioned" in flags:
|
||||
flags.append("wildcard_mentioned")
|
||||
user_data: UserData = dict(id=user_id, flags=flags, mentioned_user_group_id=None)
|
||||
|
||||
if user_id in send_request.mentioned_user_groups_map:
|
||||
|
|
|
@ -262,7 +262,15 @@ def messages_for_ids(
|
|||
|
||||
for message_id in message_ids:
|
||||
msg_dict = message_dicts[message_id]
|
||||
msg_dict.update(flags=user_message_flags[message_id])
|
||||
flags = user_message_flags[message_id]
|
||||
# TODO/compatibility: The `wildcard_mentioned` flag was deprecated in favor of
|
||||
# the `stream_wildcard_mentioned` and `topic_wildcard_mentioned` flags. The
|
||||
# `wildcard_mentioned` flag exists for backwards-compatibility with older
|
||||
# clients. Remove this when we no longer support legacy clients that have not
|
||||
# been updated to access `stream_wildcard_mentioned`.
|
||||
if "stream_wildcard_mentioned" in flags or "topic_wildcard_mentioned" in flags:
|
||||
flags.append("wildcard_mentioned")
|
||||
msg_dict.update(flags=flags)
|
||||
if message_id in search_fields:
|
||||
msg_dict.update(search_fields[message_id])
|
||||
# Make sure that we never send message edit history to clients
|
||||
|
@ -1189,13 +1197,15 @@ def extract_unread_data_from_um_rows(
|
|||
|
||||
# TODO: Add support for alert words here as well.
|
||||
is_mentioned = (row["flags"] & UserMessage.flags.mentioned) != 0
|
||||
is_wildcard_mentioned = (row["flags"] & UserMessage.flags.wildcard_mentioned) != 0
|
||||
is_stream_wildcard_mentioned = (
|
||||
row["flags"] & UserMessage.flags.stream_wildcard_mentioned
|
||||
) != 0
|
||||
is_topic_wildcard_mentioned = (
|
||||
row["flags"] & UserMessage.flags.topic_wildcard_mentioned
|
||||
) != 0
|
||||
if is_mentioned:
|
||||
mentions.add(message_id)
|
||||
if is_wildcard_mentioned or is_topic_wildcard_mentioned:
|
||||
if is_stream_wildcard_mentioned or is_topic_wildcard_mentioned:
|
||||
if msg_type == Recipient.STREAM:
|
||||
stream_id = row["message__recipient__type_id"]
|
||||
topic = row[MESSAGE__TOPIC]
|
||||
|
@ -1373,7 +1383,7 @@ def apply_unread_message_event(
|
|||
if "mentioned" in flags:
|
||||
state["mentions"].add(message_id)
|
||||
if (
|
||||
"wildcard_mentioned" in flags or "topic_wildcard_mentioned" in flags
|
||||
"stream_wildcard_mentioned" in flags or "topic_wildcard_mentioned" in flags
|
||||
) and message_id in state["unmuted_stream_msgs"]:
|
||||
state["mentions"].add(message_id)
|
||||
|
||||
|
|
|
@ -364,7 +364,7 @@ class NarrowBuilder:
|
|||
elif operand == "mentioned":
|
||||
mention_flags_mask = (
|
||||
UserMessage.flags.mentioned.mask
|
||||
| UserMessage.flags.wildcard_mentioned.mask
|
||||
| UserMessage.flags.stream_wildcard_mentioned.mask
|
||||
| UserMessage.flags.topic_wildcard_mentioned.mask
|
||||
| UserMessage.flags.group_mentioned.mask
|
||||
)
|
||||
|
|
|
@ -111,7 +111,7 @@ class UserMessageNotificationsData:
|
|||
stream_wildcard_mention_email_notify = (
|
||||
user_id in stream_wildcard_mention_user_ids
|
||||
and user_id not in dm_mention_email_disabled_user_ids
|
||||
and "wildcard_mentioned" in flags
|
||||
and "stream_wildcard_mentioned" in flags
|
||||
)
|
||||
topic_wildcard_mention_in_followed_topic_email_notify = (
|
||||
user_id in topic_wildcard_mention_in_followed_topic_user_ids
|
||||
|
@ -121,7 +121,7 @@ class UserMessageNotificationsData:
|
|||
stream_wildcard_mention_in_followed_topic_email_notify = (
|
||||
user_id in stream_wildcard_mention_in_followed_topic_user_ids
|
||||
and user_id not in dm_mention_email_disabled_user_ids
|
||||
and "wildcard_mentioned" in flags
|
||||
and "stream_wildcard_mentioned" in flags
|
||||
)
|
||||
|
||||
dm_push_notify = user_id not in dm_mention_push_disabled_user_ids and private_message
|
||||
|
@ -136,7 +136,7 @@ class UserMessageNotificationsData:
|
|||
stream_wildcard_mention_push_notify = (
|
||||
user_id in stream_wildcard_mention_user_ids
|
||||
and user_id not in dm_mention_push_disabled_user_ids
|
||||
and "wildcard_mentioned" in flags
|
||||
and "stream_wildcard_mentioned" in flags
|
||||
)
|
||||
topic_wildcard_mention_in_followed_topic_push_notify = (
|
||||
user_id in topic_wildcard_mention_in_followed_topic_user_ids
|
||||
|
@ -146,7 +146,7 @@ class UserMessageNotificationsData:
|
|||
stream_wildcard_mention_in_followed_topic_push_notify = (
|
||||
user_id in stream_wildcard_mention_in_followed_topic_user_ids
|
||||
and user_id not in dm_mention_push_disabled_user_ids
|
||||
and "wildcard_mentioned" in flags
|
||||
and "stream_wildcard_mentioned" in flags
|
||||
)
|
||||
return cls(
|
||||
user_id=user_id,
|
||||
|
|
|
@ -22,7 +22,7 @@ class Migration(migrations.Migration):
|
|||
"starred",
|
||||
"collapsed",
|
||||
"mentioned",
|
||||
"wildcard_mentioned",
|
||||
"stream_wildcard_mentioned",
|
||||
"topic_wildcard_mentioned",
|
||||
"group_mentioned",
|
||||
"force_expand",
|
||||
|
@ -44,7 +44,7 @@ class Migration(migrations.Migration):
|
|||
"starred",
|
||||
"collapsed",
|
||||
"mentioned",
|
||||
"wildcard_mentioned",
|
||||
"stream_wildcard_mentioned",
|
||||
"topic_wildcard_mentioned",
|
||||
"group_mentioned",
|
||||
"force_expand",
|
||||
|
|
|
@ -3485,7 +3485,7 @@ class AbstractUserMessage(models.Model):
|
|||
"starred",
|
||||
"collapsed",
|
||||
"mentioned",
|
||||
"wildcard_mentioned",
|
||||
"stream_wildcard_mentioned",
|
||||
"topic_wildcard_mentioned",
|
||||
"group_mentioned",
|
||||
# These next 2 flags are from features that have since been removed.
|
||||
|
@ -3516,7 +3516,7 @@ class AbstractUserMessage(models.Model):
|
|||
# These flags are bookkeeping and don't make sense to edit.
|
||||
"has_alert_word",
|
||||
"mentioned",
|
||||
"wildcard_mentioned",
|
||||
"stream_wildcard_mentioned",
|
||||
"topic_wildcard_mentioned",
|
||||
"group_mentioned",
|
||||
"historical",
|
||||
|
@ -3615,7 +3615,7 @@ class UserMessage(AbstractUserMessage):
|
|||
"user_profile",
|
||||
"message",
|
||||
condition=Q(flags__andnz=AbstractUserMessage.flags.mentioned.mask)
|
||||
| Q(flags__andnz=AbstractUserMessage.flags.wildcard_mentioned.mask),
|
||||
| Q(flags__andnz=AbstractUserMessage.flags.stream_wildcard_mentioned.mask),
|
||||
name="zerver_usermessage_wildcard_mentioned_message_id",
|
||||
),
|
||||
models.Index(
|
||||
|
@ -3623,7 +3623,7 @@ class UserMessage(AbstractUserMessage):
|
|||
"message",
|
||||
condition=Q(
|
||||
flags__andnz=AbstractUserMessage.flags.mentioned.mask
|
||||
| AbstractUserMessage.flags.wildcard_mentioned.mask
|
||||
| AbstractUserMessage.flags.stream_wildcard_mentioned.mask
|
||||
| AbstractUserMessage.flags.topic_wildcard_mentioned.mask
|
||||
| AbstractUserMessage.flags.group_mentioned.mask
|
||||
),
|
||||
|
@ -3670,7 +3670,7 @@ class UserMessage(AbstractUserMessage):
|
|||
return UserMessage.objects.filter(
|
||||
Q(
|
||||
flags__andnz=UserMessage.flags.mentioned.mask
|
||||
| UserMessage.flags.wildcard_mentioned.mask
|
||||
| UserMessage.flags.stream_wildcard_mentioned.mask
|
||||
| UserMessage.flags.topic_wildcard_mentioned.mask
|
||||
| UserMessage.flags.group_mentioned.mask
|
||||
),
|
||||
|
|
|
@ -943,6 +943,14 @@ paths:
|
|||
in a new message that the server has already marked as read for
|
||||
the user.
|
||||
|
||||
**Changes**: In Zulip 8.0 (feature level 224), the `wildcard_mentioned` flag
|
||||
was deprecated in favor of the `stream_wildcard_mentioned` and `topic_wildcard_mentioned`
|
||||
flags. The `wildcard_mentioned` flag exists for backwards compatibility with
|
||||
older clients and equals `stream_wildcard_mentioned` || `topic_wildcard_mentioned`.
|
||||
Clients interacting with older servers should treat this field as an old name
|
||||
for `stream_wildcard_mentioned`. @topic mentions were not available prior to
|
||||
this feature level.
|
||||
|
||||
[message-flags]: /api/update-message-flags#available-flags
|
||||
items:
|
||||
type: string
|
||||
|
@ -2343,6 +2351,14 @@ paths:
|
|||
to identify cases where a mention or alert word was added by the
|
||||
edit.
|
||||
|
||||
**Changes**: In Zulip 8.0 (feature level 224), the `wildcard_mentioned` flag
|
||||
was deprecated in favor of the `stream_wildcard_mentioned` and `topic_wildcard_mentioned`
|
||||
flags. The `wildcard_mentioned` flag exists for backwards compatibility with
|
||||
older clients and equals `stream_wildcard_mentioned` || `topic_wildcard_mentioned`.
|
||||
Clients interacting with older servers should treat this field as an old name
|
||||
for `stream_wildcard_mentioned`. @topic mentions were not available prior to
|
||||
this feature level.
|
||||
|
||||
[message-flags]: /api/update-message-flags#available-flags
|
||||
items:
|
||||
type: string
|
||||
|
@ -6081,6 +6097,14 @@ paths:
|
|||
description: |
|
||||
The user's [message flags][message-flags] for the message.
|
||||
|
||||
**Changes**: In Zulip 8.0 (feature level 224), the `wildcard_mentioned` flag
|
||||
was deprecated in favor of the `stream_wildcard_mentioned` and `topic_wildcard_mentioned`
|
||||
flags. The `wildcard_mentioned` flag exists for backwards compatibility with
|
||||
older clients and equals `stream_wildcard_mentioned` || `topic_wildcard_mentioned`.
|
||||
Clients interacting with older servers should treat this field as an old name
|
||||
for `stream_wildcard_mentioned`. @topic mentions were not available prior to
|
||||
this feature level.
|
||||
|
||||
[message-flags]: /api/update-message-flags#available-flags
|
||||
items:
|
||||
type: string
|
||||
|
@ -6552,13 +6576,42 @@ paths:
|
|||
<tr>
|
||||
<td><code>wildcard_mentioned</code></td>
|
||||
<td>
|
||||
Whether this message contained
|
||||
<a href="/help/mention-a-user-or-group#mention-everyone-on-a-stream">wildcard mention</a>
|
||||
like @**all**. Cannot be changed by the user directly, but
|
||||
can change if the message is edited to add/remove
|
||||
a wildcard mention.
|
||||
Whether this message contained either a
|
||||
<a href="/help/mention-a-user-or-group#mention-everyone-on-a-stream">stream wildcard mention</a>
|
||||
like @**all** or a topic wildcard mention (@**topic**). Cannot be changed
|
||||
by the user directly, but can change if the message is edited to add/remove
|
||||
a stream or/and topic wildcard mention.
|
||||
|
||||
**Changes**: In Zulip 8.0 (feature level 224), the `wildcard_mentioned` flag
|
||||
was deprecated in favor of the `stream_wildcard_mentioned` and `topic_wildcard_mentioned`
|
||||
flags. The `wildcard_mentioned` flag exists for backwards compatibility with
|
||||
older clients and equals `stream_wildcard_mentioned` || `topic_wildcard_mentioned`.
|
||||
Clients interacting with older servers should treat this field as an old name
|
||||
for `stream_wildcard_mentioned`. @topic mentions were not available prior to
|
||||
this feature level.
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>stream_wildcard_mentioned</code></td>
|
||||
<td>
|
||||
Whether this message contained a
|
||||
<a href="/help/mention-a-user-or-group#mention-everyone-on-a-stream">stream wildcard mention</a>
|
||||
like @**all**. Cannot be changed by the user directly, but
|
||||
can change if the message is edited to add/remove
|
||||
a stream wildcard mention.
|
||||
|
||||
**Changes**: New in Zulip 8.0 (feature level 224).
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><code>topic_wildcard_mentioned</code></td>
|
||||
<td>
|
||||
Whether this message contained a topic wildcard mention (@**topic**).
|
||||
Cannot be changed by the user directly, but can change if
|
||||
the message is edited to add/remove a topic wildcard mention.
|
||||
|
||||
**Changes**: New in Zulip 8.0 (feature level 224).
|
||||
</td>
|
||||
<tr>
|
||||
<td><code>has_alert_word</code></td>
|
||||
<td>
|
||||
|
@ -7254,6 +7307,14 @@ paths:
|
|||
description: |
|
||||
The user's [message flags][message-flags] for the message.
|
||||
|
||||
**Changes**: In Zulip 8.0 (feature level 224), the `wildcard_mentioned` flag
|
||||
was deprecated in favor of the `stream_wildcard_mentioned` and `topic_wildcard_mentioned`
|
||||
flags. The `wildcard_mentioned` flag exists for backwards compatibility with
|
||||
older clients and equals `stream_wildcard_mentioned` || `topic_wildcard_mentioned`.
|
||||
Clients interacting with older servers should treat this field as an old name
|
||||
for `stream_wildcard_mentioned`. @topic mentions were not available prior to
|
||||
this feature level.
|
||||
|
||||
[message-flags]: /api/update-message-flags#available-flags
|
||||
items:
|
||||
type: string
|
||||
|
|
|
@ -1525,7 +1525,7 @@ class SchemaMigrationsTests(ZulipTestCase):
|
|||
),
|
||||
dict(
|
||||
id=cordelia.id,
|
||||
flags=["wildcard_mentioned"],
|
||||
flags=["stream_wildcard_mentioned"],
|
||||
mentioned=False,
|
||||
online_push_enabled=True,
|
||||
stream_push_notify=True,
|
||||
|
@ -1543,7 +1543,7 @@ class SchemaMigrationsTests(ZulipTestCase):
|
|||
),
|
||||
dict(
|
||||
id=cordelia.id,
|
||||
flags=["wildcard_mentioned"],
|
||||
flags=["stream_wildcard_mentioned"],
|
||||
),
|
||||
]
|
||||
|
||||
|
|
|
@ -2186,11 +2186,11 @@ class EditMessageTest(EditMessageTestCase):
|
|||
[
|
||||
{
|
||||
"id": hamlet.id,
|
||||
"flags": ["read", "wildcard_mentioned"],
|
||||
"flags": ["read", "stream_wildcard_mentioned"],
|
||||
},
|
||||
{
|
||||
"id": cordelia.id,
|
||||
"flags": ["wildcard_mentioned"],
|
||||
"flags": ["stream_wildcard_mentioned"],
|
||||
},
|
||||
],
|
||||
key=itemgetter("id"),
|
||||
|
@ -2330,11 +2330,11 @@ class EditMessageTest(EditMessageTestCase):
|
|||
[
|
||||
{
|
||||
"id": hamlet.id,
|
||||
"flags": ["read", "wildcard_mentioned"],
|
||||
"flags": ["read", "stream_wildcard_mentioned"],
|
||||
},
|
||||
{
|
||||
"id": cordelia.id,
|
||||
"flags": ["wildcard_mentioned"],
|
||||
"flags": ["stream_wildcard_mentioned"],
|
||||
},
|
||||
],
|
||||
key=itemgetter("id"),
|
||||
|
|
|
@ -250,7 +250,7 @@ class NarrowBuilderTest(ZulipTestCase):
|
|||
where_clause = "WHERE (flags & %(flags_1)s) = %(param_1)s"
|
||||
mention_flags_mask = (
|
||||
UserMessage.flags.mentioned.mask
|
||||
| UserMessage.flags.wildcard_mentioned.mask
|
||||
| UserMessage.flags.stream_wildcard_mentioned.mask
|
||||
| UserMessage.flags.topic_wildcard_mentioned.mask
|
||||
| UserMessage.flags.group_mentioned.mask
|
||||
)
|
||||
|
|
|
@ -1078,7 +1078,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
|
|||
# TODO: This should change when we make alert words work better.
|
||||
self.assertEqual(result["mentions"], [])
|
||||
|
||||
um.flags = UserMessage.flags.wildcard_mentioned
|
||||
um.flags = UserMessage.flags.stream_wildcard_mentioned
|
||||
um.save()
|
||||
result = get_unread_data()
|
||||
self.assertEqual(result["mentions"], [stream_message_id])
|
||||
|
@ -1111,7 +1111,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
|
|||
|
||||
# wildcard mentions don't take precedence over mutedness in
|
||||
# a normal or muted topic within a muted stream
|
||||
um.flags = UserMessage.flags.wildcard_mentioned
|
||||
um.flags = UserMessage.flags.stream_wildcard_mentioned
|
||||
um.save()
|
||||
result = get_unread_data()
|
||||
self.assertEqual(result["mentions"], [])
|
||||
|
@ -1133,7 +1133,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
|
|||
)
|
||||
# wildcard mentions take precedence over mutedness in an unmuted
|
||||
# or a followed topic within a muted stream.
|
||||
um.flags = UserMessage.flags.wildcard_mentioned
|
||||
um.flags = UserMessage.flags.stream_wildcard_mentioned
|
||||
um.save()
|
||||
result = get_unread_data()
|
||||
self.assertEqual(result["mentions"], [unmuted_topic_muted_stream_message_id])
|
||||
|
@ -1165,7 +1165,7 @@ class GetUnreadMsgsTest(ZulipTestCase):
|
|||
self.assertEqual(result["mentions"], [])
|
||||
|
||||
# wildcard mentions don't take precedence over mutedness in a muted topic.
|
||||
um.flags = UserMessage.flags.wildcard_mentioned
|
||||
um.flags = UserMessage.flags.stream_wildcard_mentioned
|
||||
um.save()
|
||||
result = get_unread_data()
|
||||
self.assertEqual(result["mentions"], [])
|
||||
|
|
|
@ -39,7 +39,7 @@ class UserMessageIndex(MigrationsTestCase):
|
|||
|
||||
um_1 = UserMessage.objects.get(id=1)
|
||||
um_1.flags.topic_wildcard_mentioned = True
|
||||
um_1.flags.wildcard_mentioned = True
|
||||
um_1.flags.stream_wildcard_mentioned = True
|
||||
um_1.flags.force_expand = True
|
||||
um_1.save()
|
||||
|
||||
|
@ -54,7 +54,7 @@ class UserMessageIndex(MigrationsTestCase):
|
|||
um_2 = UserMessage.objects.get(id=2)
|
||||
|
||||
self.assertTrue(um_1.flags.topic_wildcard_mentioned)
|
||||
self.assertTrue(um_1.flags.wildcard_mentioned)
|
||||
self.assertTrue(um_1.flags.stream_wildcard_mentioned)
|
||||
self.assertTrue(um_1.flags.force_expand)
|
||||
self.assertTrue(um_2.flags.group_mentioned)
|
||||
self.assertTrue(um_2.flags.topic_wildcard_mentioned)
|
||||
|
@ -68,7 +68,7 @@ class UserMessageIndex(MigrationsTestCase):
|
|||
um_2 = UserMessage.objects.get(id=2)
|
||||
|
||||
self.assertFalse(um_1.flags.topic_wildcard_mentioned)
|
||||
self.assertTrue(um_1.flags.wildcard_mentioned)
|
||||
self.assertTrue(um_1.flags.stream_wildcard_mentioned)
|
||||
self.assertFalse(um_1.flags.force_expand)
|
||||
self.assertFalse(um_2.flags.group_mentioned)
|
||||
self.assertFalse(um_2.flags.topic_wildcard_mentioned)
|
||||
|
|
Loading…
Reference in New Issue