diff --git a/api_docs/changelog.md b/api_docs/changelog.md index 9f085b3745..b4b649da4e 100644 --- a/api_docs/changelog.md +++ b/api_docs/changelog.md @@ -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`: diff --git a/version.py b/version.py index 8e82f0217f..c04610ef21 100644 --- a/version.py +++ b/version.py @@ -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 diff --git a/web/src/markdown.js b/web/src/markdown.js index 9ebaea2ae7..c89e5de21a 100644 --- a/web/src/markdown.js +++ b/web/src/markdown.js @@ -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}; diff --git a/web/src/message_edit.js b/web/src/message_edit.js index 1477f54259..89fd92b2d1 100644 --- a/web/src/message_edit.js +++ b/web/src/message_edit.js @@ -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({ diff --git a/web/src/message_store.js b/web/src/message_store.js index 8856a34120..87b0abf61c 100644 --- a/web/src/message_store.js +++ b/web/src/message_store.js @@ -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"); } diff --git a/web/src/types.ts b/web/src/types.ts index 140587b6e1..571e8a7311 100644 --- a/web/src/types.ts +++ b/web/src/types.ts @@ -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; }; diff --git a/web/tests/markdown.test.js b/web/tests/markdown.test.js index 573b5c3eff..50513127ae 100644 --- a/web/tests/markdown.test.js +++ b/web/tests/markdown.test.js @@ -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); }); diff --git a/web/tests/message_events.test.js b/web/tests/message_events.test.js index 8cde765ce2..15823b31b0 100644 --- a/web/tests/message_events.test.js +++ b/web/tests/message_events.test.js @@ -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: [], diff --git a/web/tests/message_store.test.js b/web/tests/message_store.test.js index 5956241630..36cc759b16 100644 --- a/web/tests/message_store.test.js +++ b/web/tests/message_store.test.js @@ -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; diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py index d7d768bc00..2c18afdedd 100644 --- a/zerver/actions/message_edit.py +++ b/zerver/actions/message_edit.py @@ -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) diff --git a/zerver/actions/message_send.py b/zerver/actions/message_send.py index d46002f0dc..878f111a88 100644 --- a/zerver/actions/message_send.py +++ b/zerver/actions/message_send.py @@ -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: diff --git a/zerver/lib/message.py b/zerver/lib/message.py index 304f74c1f9..e5cb1ec0e4 100644 --- a/zerver/lib/message.py +++ b/zerver/lib/message.py @@ -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) diff --git a/zerver/lib/narrow.py b/zerver/lib/narrow.py index 7d0efead5a..0bdb8fc2a1 100644 --- a/zerver/lib/narrow.py +++ b/zerver/lib/narrow.py @@ -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 ) diff --git a/zerver/lib/notification_data.py b/zerver/lib/notification_data.py index 24d39c21c0..29abe63dc0 100644 --- a/zerver/lib/notification_data.py +++ b/zerver/lib/notification_data.py @@ -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, diff --git a/zerver/migrations/0485_alter_usermessage_flags_and_add_index.py b/zerver/migrations/0485_alter_usermessage_flags_and_add_index.py index 92032de244..992a550ec6 100644 --- a/zerver/migrations/0485_alter_usermessage_flags_and_add_index.py +++ b/zerver/migrations/0485_alter_usermessage_flags_and_add_index.py @@ -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", diff --git a/zerver/models.py b/zerver/models.py index f33992f9f9..05885499cb 100644 --- a/zerver/models.py +++ b/zerver/models.py @@ -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 ), diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 2b87427269..f481721aad 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -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: wildcard_mentioned - Whether this message contained - wildcard mention - 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 + stream wildcard mention + 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. + + stream_wildcard_mentioned + + Whether this message contained a + stream wildcard mention + 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). + + + + topic_wildcard_mentioned + + 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). + has_alert_word @@ -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 diff --git a/zerver/tests/test_event_queue.py b/zerver/tests/test_event_queue.py index 331feb9f90..d7697bd341 100644 --- a/zerver/tests/test_event_queue.py +++ b/zerver/tests/test_event_queue.py @@ -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"], ), ] diff --git a/zerver/tests/test_message_edit.py b/zerver/tests/test_message_edit.py index 496b23a3d9..8ff9a4fc24 100644 --- a/zerver/tests/test_message_edit.py +++ b/zerver/tests/test_message_edit.py @@ -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"), diff --git a/zerver/tests/test_message_fetch.py b/zerver/tests/test_message_fetch.py index f99a75a384..e08d4472d6 100644 --- a/zerver/tests/test_message_fetch.py +++ b/zerver/tests/test_message_fetch.py @@ -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 ) diff --git a/zerver/tests/test_message_flags.py b/zerver/tests/test_message_flags.py index e1ed8b43fd..9d10962079 100644 --- a/zerver/tests/test_message_flags.py +++ b/zerver/tests/test_message_flags.py @@ -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"], []) diff --git a/zerver/tests/test_migrations.py b/zerver/tests/test_migrations.py index 775df86ceb..8f02025900 100644 --- a/zerver/tests/test_migrations.py +++ b/zerver/tests/test_migrations.py @@ -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)