Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message: Do not differentiate topics by case when aggregating.

Alex Vandivered8058d060c8
diff --git a/zerver/lib/message.py b/zerver/lib/message.py
index 0e16d69bbc3..dc5f89beae3 100644
--- a/zerver/lib/message.py
+++ b/zerver/lib/message.py
@@ -730,7 +730,7 @@ def aggregate_streams(*, input_dict: dict[int, RawUnreadStreamDict]) -> list[Unr
for message_id, attribute_dict in input_dict.items():
stream_id = attribute_dict["stream_id"]
topic_name = attribute_dict["topic"]
- lookup_key = (stream_id, topic_name)
+ lookup_key = (stream_id, topic_name.lower())
if lookup_key not in lookup_dict:
obj = UnreadStreamInfo(
stream_id=stream_id,
diff --git a/zerver/tests/test_event_system.py b/zerver/tests/test_event_system.py
index f78eb99a821..fbb9366d34c 100644
--- a/zerver/tests/test_event_system.py
+++ b/zerver/tests/test_event_system.py
@@ -17,7 +17,7 @@ from zerver.actions.presence import do_update_user_presence
from zerver.actions.user_settings import do_change_user_setting
from zerver.actions.users import do_change_user_role
from zerver.lib.event_schema import check_web_reload_client_event
-from zerver.lib.events import fetch_initial_state_data
+from zerver.lib.events import fetch_initial_state_data, post_process_state
from zerver.lib.exceptions import AccessDeniedError
from zerver.lib.request import RequestVariableMissingError
from zerver.lib.test_classes import ZulipTestCase
@@ -828,6 +828,22 @@ class FetchInitialStateDataTest(ZulipTestCase):
[pronouns_field] = (field for field in custom_profile_fields if field["name"] == "Pronouns")
self.assertEqual(pronouns_field["type"], CustomProfileField.PRONOUNS)
+ def test_unreads_case_insensitive_topics(self) -> None:
+ sender = self.example_user("hamlet")
+ self.login_user(sender)
+ self.send_stream_message(sender, "Denmark", "**hello**", topic_name="case DOES not MATTER")
+ self.send_stream_message(sender, "Denmark", "**bye**", topic_name="CASE does NOT matter")
+
+ reader = self.example_user("othello")
+ result = fetch_initial_state_data(
+ user_profile=reader,
+ realm=reader.realm,
+ )
+ post_process_state(reader, result, False)
+ self.assert_length(result["unread_msgs"]["streams"], 1)
+ self.assertEqual(result["unread_msgs"]["streams"][0]["topic"], "case DOES not MATTER")
+ self.assert_length(result["unread_msgs"]["streams"][0]["unread_message_ids"], 2)
+
class ClientDescriptorsTest(ZulipTestCase):
def test_get_client_info_for_all_public_streams(self) -> None: