diff --git a/zerver/actions/default_streams.py b/zerver/actions/default_streams.py index 015adc2e75..da999cf3e4 100644 --- a/zerver/actions/default_streams.py +++ b/zerver/actions/default_streams.py @@ -17,11 +17,11 @@ from zerver.tornado.django_api import send_event_on_commit def check_default_stream_group_name(group_name: str) -> None: if group_name.strip() == "": raise JsonableError( - _("Invalid default stream group name '{group_name}'").format(group_name=group_name) + _("Invalid default channel group name '{group_name}'").format(group_name=group_name) ) if len(group_name) > DefaultStreamGroup.MAX_NAME_LENGTH: raise JsonableError( - _("Default stream group name too long (limit: {max_length} characters)").format( + _("Default channel group name too long (limit: {max_length} characters)").format( max_length=DefaultStreamGroup.MAX_NAME_LENGTH, ) ) @@ -29,7 +29,7 @@ def check_default_stream_group_name(group_name: str) -> None: if ord(i) == 0: raise JsonableError( _( - "Default stream group name '{group_name}' contains NULL (0x00) characters." + "Default channel group name '{group_name}' contains NULL (0x00) characters." ).format( group_name=group_name, ) @@ -45,7 +45,7 @@ def lookup_default_stream_groups( default_stream_group = DefaultStreamGroup.objects.get(name=group_name, realm=realm) except DefaultStreamGroup.DoesNotExist: raise JsonableError( - _("Invalid default stream group {group_name}").format(group_name=group_name) + _("Invalid default channel group {group_name}").format(group_name=group_name) ) default_stream_groups.append(default_stream_group) return default_stream_groups @@ -93,7 +93,7 @@ def do_create_default_stream_group( if stream.id in default_stream_ids: raise JsonableError( _( - "'{channel_name}' is a default stream and cannot be added to '{group_name}'", + "'{channel_name}' is a default channel and cannot be added to '{group_name}'", ).format(channel_name=stream.name, group_name=group_name) ) @@ -104,7 +104,7 @@ def do_create_default_stream_group( if not created: raise JsonableError( _( - "Default stream group '{group_name}' already exists", + "Default channel group '{group_name}' already exists", ).format(group_name=group_name) ) @@ -120,13 +120,13 @@ def do_add_streams_to_default_stream_group( if stream.id in default_stream_ids: raise JsonableError( _( - "'{channel_name}' is a default stream and cannot be added to '{group_name}'", + "'{channel_name}' is a default channel and cannot be added to '{group_name}'", ).format(channel_name=stream.name, group_name=group.name) ) if stream in group.streams.all(): raise JsonableError( _( - "Stream '{channel_name}' is already present in default stream group '{group_name}'", + "Channel '{channel_name}' is already present in default channel group '{group_name}'", ).format(channel_name=stream.name, group_name=group.name) ) group.streams.add(stream) @@ -143,7 +143,7 @@ def do_remove_streams_from_default_stream_group( if stream.id not in group_stream_ids: raise JsonableError( _( - "Stream '{channel_name}' is not present in default stream group '{group_name}'", + "Channel '{channel_name}' is not present in default channel group '{group_name}'", ).format(channel_name=stream.name, group_name=group.name) ) @@ -158,14 +158,14 @@ def do_change_default_stream_group_name( ) -> None: if group.name == new_group_name: raise JsonableError( - _("This default stream group is already named '{group_name}'").format( + _("This default channel group is already named '{group_name}'").format( group_name=new_group_name ) ) if DefaultStreamGroup.objects.filter(name=new_group_name, realm=realm).exists(): raise JsonableError( - _("Default stream group '{group_name}' already exists").format( + _("Default channel group '{group_name}' already exists").format( group_name=new_group_name ) ) diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py index 93a01a7832..c2788d8d49 100644 --- a/zerver/actions/message_edit.py +++ b/zerver/actions/message_edit.py @@ -103,7 +103,7 @@ def validate_message_edit_payload( if not message.is_stream_message(): if stream_id is not None: - raise JsonableError(_("Direct messages cannot be moved to streams.")) + raise JsonableError(_("Direct messages cannot be moved to channels.")) if topic_name is not None: raise JsonableError(_("Direct messages cannot have topics.")) @@ -114,7 +114,7 @@ def validate_message_edit_payload( check_stream_topic(topic_name) if stream_id is not None and content is not None: - raise JsonableError(_("Cannot change message content while changing stream")) + raise JsonableError(_("Cannot change message content while changing channel")) # Right now, we prevent users from editing widgets. if content is not None and is_widget_message(message): @@ -1325,7 +1325,7 @@ def check_update_message( ) if (timezone_now() - message.date_sent) > timedelta(seconds=deadline_seconds): raise JsonableError( - _("The time limit for editing this message's stream has passed") + _("The time limit for editing this message's channel has passed") ) if ( diff --git a/zerver/lib/addressee.py b/zerver/lib/addressee.py index ccffd7207e..2a1ac0eeb4 100644 --- a/zerver/lib/addressee.py +++ b/zerver/lib/addressee.py @@ -108,7 +108,7 @@ class Addressee: if recipient_type_name == "stream": if len(message_to) > 1: - raise JsonableError(_("Cannot send to multiple streams")) + raise JsonableError(_("Cannot send to multiple channels")) if message_to: stream_name_or_id = message_to[0] @@ -120,7 +120,7 @@ class Addressee: # Use the user's default stream stream_name_or_id = sender.default_sending_stream_id else: - raise JsonableError(_("Missing stream")) + raise JsonableError(_("Missing channel")) if topic_name is None: raise JsonableError(_("Missing topic")) diff --git a/zerver/lib/drafts.py b/zerver/lib/drafts.py index be34f7be85..eca1b2110b 100644 --- a/zerver/lib/drafts.py +++ b/zerver/lib/drafts.py @@ -60,7 +60,7 @@ def further_validated_draft_dict( if "\0" in topic_name: raise JsonableError(_("Topic must not contain null bytes")) if len(to) != 1: - raise JsonableError(_("Must specify exactly 1 stream ID for stream messages")) + raise JsonableError(_("Must specify exactly 1 channel ID for channel messages")) stream, sub = access_stream_by_id(user_profile, to[0]) recipient_id = stream.recipient_id elif draft_dict.type == "private" and len(to) != 0: diff --git a/zerver/lib/recipient_parsing.py b/zerver/lib/recipient_parsing.py index 78fd6b17f4..2386cdb4fd 100644 --- a/zerver/lib/recipient_parsing.py +++ b/zerver/lib/recipient_parsing.py @@ -11,7 +11,7 @@ def extract_stream_id(req_to: str) -> int: try: stream_id = int(req_to) except ValueError: - raise JsonableError(_("Invalid data type for stream ID")) + raise JsonableError(_("Invalid data type for channel ID")) return stream_id diff --git a/zerver/lib/string_validation.py b/zerver/lib/string_validation.py index b7c3f329a1..e5b387bba1 100644 --- a/zerver/lib/string_validation.py +++ b/zerver/lib/string_validation.py @@ -38,11 +38,11 @@ def check_string_is_printable(var: str) -> Optional[int]: def check_stream_name(stream_name: str) -> None: if stream_name.strip() == "": - raise JsonableError(_("Stream name can't be empty!")) + raise JsonableError(_("Channel name can't be empty.")) if len(stream_name) > Stream.MAX_NAME_LENGTH: raise JsonableError( - _("Stream name too long (limit: {max_length} characters).").format( + _("Channel name too long (limit: {max_length} characters).").format( max_length=Stream.MAX_NAME_LENGTH ) ) @@ -50,7 +50,7 @@ def check_stream_name(stream_name: str) -> None: invalid_character_pos = check_string_is_printable(stream_name) if invalid_character_pos is not None: raise JsonableError( - _("Invalid character in stream name, at position {position}!").format( + _("Invalid character in channel name, at position {position}.").format( position=invalid_character_pos ) ) diff --git a/zerver/lib/subscription_info.py b/zerver/lib/subscription_info.py index e1abad74da..ae31267285 100644 --- a/zerver/lib/subscription_info.py +++ b/zerver/lib/subscription_info.py @@ -329,14 +329,14 @@ def validate_user_access_to_subscribers_helper( # Adding an `else` would ensure better code coverage. if not user_profile.can_access_public_streams() and not stream_dict["invite_only"]: - raise JsonableError(_("Subscriber data is not available for this stream")) + raise JsonableError(_("Subscriber data is not available for this channel")) # Organization administrators can view subscribers for all streams. if user_profile.is_realm_admin: return if stream_dict["invite_only"] and not check_user_subscribed(user_profile): - raise JsonableError(_("Unable to retrieve subscribers for private stream")) + raise JsonableError(_("Unable to retrieve subscribers for private channel")) def bulk_get_subscriber_user_ids( diff --git a/zerver/openapi/zulip.yaml b/zerver/openapi/zulip.yaml index 4e3a46b002..a068105857 100644 --- a/zerver/openapi/zulip.yaml +++ b/zerver/openapi/zulip.yaml @@ -5517,7 +5517,7 @@ paths: example: { "code": "BAD_REQUEST", - "msg": "Must specify exactly 1 stream ID for stream messages", + "msg": "Must specify exactly 1 channel ID for channel messages", "result": "error", } /drafts/{draft_id}: @@ -18321,7 +18321,7 @@ paths: - example: { "code": "BAD_REQUEST", - "msg": "Missing stream_id", + "msg": "Missing channel ID", "result": "error", } description: | diff --git a/zerver/tests/test_drafts.py b/zerver/tests/test_drafts.py index 2ddfb0a811..186e69a74d 100644 --- a/zerver/tests/test_drafts.py +++ b/zerver/tests/test_drafts.py @@ -240,7 +240,7 @@ class DraftCreationTests(ZulipTestCase): } ] self.create_and_check_drafts_for_error( - draft_dicts, "Must specify exactly 1 stream ID for stream messages" + draft_dicts, "Must specify exactly 1 channel ID for channel messages" ) def test_create_stream_draft_for_inaccessible_stream(self) -> None: diff --git a/zerver/tests/test_message_move_stream.py b/zerver/tests/test_message_move_stream.py index 607b79f756..54023cb7e1 100644 --- a/zerver/tests/test_message_move_stream.py +++ b/zerver/tests/test_message_move_stream.py @@ -76,7 +76,7 @@ class MessageMoveStreamTest(ZulipTestCase): }, ) - self.assert_json_error(result, "Direct messages cannot be moved to streams.") + self.assert_json_error(result, "Direct messages cannot be moved to channels.") def test_move_message_to_stream_with_content(self) -> None: (user_profile, old_stream, new_stream, msg_id, msg_id_later) = self.prepare_move_topics( @@ -91,7 +91,7 @@ class MessageMoveStreamTest(ZulipTestCase): "content": "Not allowed", }, ) - self.assert_json_error(result, "Cannot change message content while changing stream") + self.assert_json_error(result, "Cannot change message content while changing channel") messages = get_topic_messages(user_profile, old_stream, "test") self.assert_length(messages, 3) @@ -943,7 +943,7 @@ class MessageMoveStreamTest(ZulipTestCase): cordelia, test_stream_1, test_stream_2, - expect_error_message="The time limit for editing this message's stream has passed", + expect_error_message="The time limit for editing this message's channel has passed", ) # admins and moderators can move messages irrespective of time limit. diff --git a/zerver/tests/test_recipient_parsing.py b/zerver/tests/test_recipient_parsing.py index a485e334bf..029555186f 100644 --- a/zerver/tests/test_recipient_parsing.py +++ b/zerver/tests/test_recipient_parsing.py @@ -11,13 +11,13 @@ class TestRecipientParsing(ZulipTestCase): stream_id = extract_stream_id("1") self.assertEqual(stream_id, 1) - with self.assertRaisesRegex(JsonableError, "Invalid data type for stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid data type for channel ID"): extract_stream_id("1,2") - with self.assertRaisesRegex(JsonableError, "Invalid data type for stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid data type for channel ID"): extract_stream_id("[1]") - with self.assertRaisesRegex(JsonableError, "Invalid data type for stream ID"): + with self.assertRaisesRegex(JsonableError, "Invalid data type for channel ID"): extract_stream_id("general") def test_extract_recipient_ids(self) -> None: diff --git a/zerver/tests/test_scheduled_messages.py b/zerver/tests/test_scheduled_messages.py index 8e492a52c5..364af0601c 100644 --- a/zerver/tests/test_scheduled_messages.py +++ b/zerver/tests/test_scheduled_messages.py @@ -505,7 +505,7 @@ class ScheduledMessageTest(ZulipTestCase): } result = self.client_patch(f"/json/scheduled_messages/{scheduled_message_id}", payload) self.assert_json_error( - result, "Topic required when updating scheduled message type to stream." + result, "Topic required when updating scheduled message type to channel." ) # Edit message `type` to stream with valid `to` and `topic` succeeds diff --git a/zerver/tests/test_subs.py b/zerver/tests/test_subs.py index 37a306a042..f0c575fc73 100644 --- a/zerver/tests/test_subs.py +++ b/zerver/tests/test_subs.py @@ -3071,7 +3071,7 @@ class DefaultStreamGroupTest(ZulipTestCase): # Test creating a default stream group which contains a default stream do_add_default_stream(remaining_streams[0]) with self.assertRaisesRegex( - JsonableError, "'stream1' is a default stream and cannot be added to 'new group1'" + JsonableError, "'stream1' is a default channel and cannot be added to 'new group1'" ): do_create_default_stream_group( realm, new_group_name, "This is group1", remaining_streams @@ -3118,7 +3118,7 @@ class DefaultStreamGroupTest(ZulipTestCase): "stream_names": orjson.dumps(stream_names).decode(), }, ) - self.assert_json_error(result, "Default stream group 'group1' already exists") + self.assert_json_error(result, "Default channel group 'group1' already exists") # Test adding streams to existing default stream group group_id = default_stream_groups[0].id @@ -3156,7 +3156,7 @@ class DefaultStreamGroupTest(ZulipTestCase): {"op": "add", "stream_names": orjson.dumps(new_stream_names).decode()}, ) self.assert_json_error( - result, "'stream4' is a default stream and cannot be added to 'group1'" + result, "'stream4' is a default channel and cannot be added to 'group1'" ) do_remove_default_stream(new_streams[0]) @@ -3175,7 +3175,7 @@ class DefaultStreamGroupTest(ZulipTestCase): {"op": "add", "stream_names": orjson.dumps(new_stream_names).decode()}, ) self.assert_json_error( - result, "Stream 'stream4' is already present in default stream group 'group1'" + result, "Channel 'stream4' is already present in default channel group 'group1'" ) # Test removing streams from default stream group @@ -3207,7 +3207,7 @@ class DefaultStreamGroupTest(ZulipTestCase): {"op": "remove", "stream_names": orjson.dumps(new_stream_names).decode()}, ) self.assert_json_error( - result, "Stream 'stream4' is not present in default stream group 'group1'" + result, "Channel 'stream4' is not present in default channel group 'group1'" ) # Test changing description of default stream group @@ -3239,7 +3239,7 @@ class DefaultStreamGroupTest(ZulipTestCase): f"/json/default_stream_groups/{group_id}", {"new_group_name": "group2"}, ) - self.assert_json_error(result, "Default stream group 'group2' already exists") + self.assert_json_error(result, "Default channel group 'group2' already exists") new_group = lookup_default_stream_groups(["group2"], realm)[0] do_remove_default_stream_group(realm, new_group) @@ -3247,7 +3247,7 @@ class DefaultStreamGroupTest(ZulipTestCase): f"/json/default_stream_groups/{group_id}", {"new_group_name": group_name}, ) - self.assert_json_error(result, "This default stream group is already named 'group1'") + self.assert_json_error(result, "This default channel group is already named 'group1'") result = self.client_patch( f"/json/default_stream_groups/{group_id}", @@ -3288,7 +3288,7 @@ class DefaultStreamGroupTest(ZulipTestCase): "stream_names": orjson.dumps(stream_names).decode(), }, ) - self.assert_json_error(result, "Invalid default stream group name ''") + self.assert_json_error(result, "Invalid default channel group name ''") result = self.client_post( "/json/default_stream_groups/create", @@ -3300,7 +3300,7 @@ class DefaultStreamGroupTest(ZulipTestCase): ) self.assert_json_error( result, - f"Default stream group name too long (limit: {DefaultStreamGroup.MAX_NAME_LENGTH} characters)", + f"Default channel group name too long (limit: {DefaultStreamGroup.MAX_NAME_LENGTH} characters)", ) result = self.client_post( @@ -3312,14 +3312,14 @@ class DefaultStreamGroupTest(ZulipTestCase): }, ) self.assert_json_error( - result, "Default stream group name 'abc\000' contains NULL (0x00) characters." + result, "Default channel group name 'abc\000' contains NULL (0x00) characters." ) # Also test that lookup_default_stream_groups raises an # error if we pass it a bad name. This function is used # during registration, but it's a bit heavy to do a full # test of that. - with self.assertRaisesRegex(JsonableError, "Invalid default stream group invalid-name"): + with self.assertRaisesRegex(JsonableError, "Invalid default channel group invalid-name"): lookup_default_stream_groups(["invalid-name"], realm) @@ -3917,7 +3917,7 @@ class SubscriptionRestApiTest(ZulipTestCase): "delete": orjson.dumps([invalid_stream_name]).decode(), } result = self.api_patch(user, "/api/v1/users/me/subscriptions", request) - self.assert_json_error(result, "Stream name can't be empty!") + self.assert_json_error(result, "Channel name can't be empty.") def test_stream_name_too_long(self) -> None: user = self.example_user("hamlet") @@ -3928,7 +3928,7 @@ class SubscriptionRestApiTest(ZulipTestCase): "delete": orjson.dumps([long_stream_name]).decode(), } result = self.api_patch(user, "/api/v1/users/me/subscriptions", request) - self.assert_json_error(result, "Stream name too long (limit: 60 characters).") + self.assert_json_error(result, "Channel name too long (limit: 60 characters).") def test_stream_name_contains_null(self) -> None: user = self.example_user("hamlet") @@ -3939,7 +3939,7 @@ class SubscriptionRestApiTest(ZulipTestCase): "delete": orjson.dumps([stream_name]).decode(), } result = self.api_patch(user, "/api/v1/users/me/subscriptions", request) - self.assert_json_error(result, "Invalid character in stream name, at position 4!") + self.assert_json_error(result, "Invalid character in channel name, at position 4.") def test_compose_views_rollback(self) -> None: """ @@ -4015,7 +4015,7 @@ class SubscriptionAPITest(ZulipTestCase): result = self.api_post( user, "/api/v1/users/me/subscriptions", post_data_cc, subdomain="zulip" ) - self.assert_json_error(result, "Invalid character in stream name, at position 4!") + self.assert_json_error(result, "Invalid character in channel name, at position 4.") # For Cn category post_data_cn = { @@ -4027,7 +4027,7 @@ class SubscriptionAPITest(ZulipTestCase): result = self.api_post( user, "/api/v1/users/me/subscriptions", post_data_cn, subdomain="zulip" ) - self.assert_json_error(result, "Invalid character in stream name, at position 4!") + self.assert_json_error(result, "Invalid character in channel name, at position 4.") def test_invalid_stream_rename(self) -> None: """ @@ -4039,16 +4039,16 @@ class SubscriptionAPITest(ZulipTestCase): do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None) # Check for empty name result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": ""}) - self.assert_json_error(result, "Stream name can't be empty!") + self.assert_json_error(result, "Channel name can't be empty.") # Check for long name result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "a" * 61}) - self.assert_json_error(result, "Stream name too long (limit: 60 characters).") + self.assert_json_error(result, "Channel name too long (limit: 60 characters).") # Check for Cc characters result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "test\n\rname"}) - self.assert_json_error(result, "Invalid character in stream name, at position 5!") + self.assert_json_error(result, "Invalid character in channel name, at position 5.") # Check for Cn characters result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "test\ufffeame"}) - self.assert_json_error(result, "Invalid character in stream name, at position 5!") + self.assert_json_error(result, "Invalid character in channel name, at position 5.") def test_successful_subscriptions_list(self) -> None: """ @@ -4329,7 +4329,7 @@ class SubscriptionAPITest(ZulipTestCase): result = self.common_subscribe_to_streams( self.test_user, [long_stream_name], allow_fail=True ) - self.assert_json_error(result, "Stream name too long (limit: 60 characters).") + self.assert_json_error(result, "Channel name too long (limit: 60 characters).") def test_subscriptions_add_stream_with_null(self) -> None: """ @@ -4338,7 +4338,7 @@ class SubscriptionAPITest(ZulipTestCase): """ stream_name = "abc\000" result = self.common_subscribe_to_streams(self.test_user, [stream_name], allow_fail=True) - self.assert_json_error(result, "Invalid character in stream name, at position 4!") + self.assert_json_error(result, "Invalid character in channel name, at position 4.") def _test_user_settings_for_creating_streams( self, @@ -4594,7 +4594,7 @@ class SubscriptionAPITest(ZulipTestCase): result = self.common_subscribe_to_streams( self.test_user, [invalid_stream_name], allow_fail=True ) - self.assert_json_error(result, "Stream name can't be empty!") + self.assert_json_error(result, "Channel name can't be empty.") def assert_adding_subscriptions_for_principal( self, diff --git a/zerver/tests/test_typing.py b/zerver/tests/test_typing.py index 9e94e226c7..80fee5033c 100644 --- a/zerver/tests/test_typing.py +++ b/zerver/tests/test_typing.py @@ -105,7 +105,7 @@ class TypingValidateStreamIdTopicArgumentsTest(ZulipTestCase): "/api/v1/typing", {"type": "stream", "op": "start", "topic": "test"}, ) - self.assert_json_error(result, "Missing stream_id") + self.assert_json_error(result, "Missing 'stream_id' argument") def test_invalid_stream_id(self) -> None: """ @@ -583,7 +583,9 @@ class TestSendTypingNotificationsSettings(ZulipTestCase): # No events should be sent now with self.capture_send_event_calls(expected_num_events=0) as events: result = self.api_post(sender, "/api/v1/typing", params) - self.assert_json_error(result, "User has disabled typing notifications for stream messages") + self.assert_json_error( + result, "User has disabled typing notifications for channel messages" + ) self.assertEqual(events, []) def test_typing_notifications_disabled(self) -> None: diff --git a/zerver/views/scheduled_messages.py b/zerver/views/scheduled_messages.py index ec1412291d..cc01ef047f 100644 --- a/zerver/views/scheduled_messages.py +++ b/zerver/views/scheduled_messages.py @@ -73,7 +73,7 @@ def update_scheduled_message_backend( recipient_type_name = "stream" if recipient_type_name is not None and recipient_type_name == "stream" and topic_name is None: - raise JsonableError(_("Topic required when updating scheduled message type to stream.")) + raise JsonableError(_("Topic required when updating scheduled message type to channel.")) if recipient_type_name is not None and recipient_type_name == "direct": # For now, use "private" from Message.API_RECIPIENT_TYPES. diff --git a/zerver/views/typing.py b/zerver/views/typing.py index 028d5db667..57f5f1c3a9 100644 --- a/zerver/views/typing.py +++ b/zerver/views/typing.py @@ -38,13 +38,13 @@ def send_notification_backend( if recipient_type_name == "stream": if stream_id is None: - raise JsonableError(_("Missing stream_id")) + raise JsonableError(_("Missing '{var_name}' argument").format(var_name="stream_id")) if topic is None: raise JsonableError(_("Missing topic")) if not user_profile.send_stream_typing_notifications: - raise JsonableError(_("User has disabled typing notifications for stream messages")) + raise JsonableError(_("User has disabled typing notifications for channel messages")) # Verify that the user has access to the stream and has # permission to send messages to it.