mirror of https://github.com/zulip/zulip.git
message-send: Update translated errors for stream to channel rename.
In zerver/actions/message_send.py, updates translated error strings to use channel instead of stream. Also, updates the messages sent to bot owners when a stream doesn't exist or has no subscribers. Part of stream to channel rename project.
This commit is contained in:
parent
acb54a8bc5
commit
c1f1dc4b25
|
@ -1260,7 +1260,7 @@ def extract_stream_indicator(s: str) -> Union[str, int]:
|
||||||
# once we improve our documentation.
|
# once we improve our documentation.
|
||||||
if isinstance(data, list):
|
if isinstance(data, list):
|
||||||
if len(data) != 1: # nocoverage
|
if len(data) != 1: # nocoverage
|
||||||
raise JsonableError(_("Expected exactly one stream"))
|
raise JsonableError(_("Expected exactly one channel"))
|
||||||
data = data[0]
|
data = data[0]
|
||||||
|
|
||||||
if isinstance(data, str):
|
if isinstance(data, str):
|
||||||
|
@ -1271,7 +1271,7 @@ def extract_stream_indicator(s: str) -> Union[str, int]:
|
||||||
# We had a stream id.
|
# We had a stream id.
|
||||||
return data
|
return data
|
||||||
|
|
||||||
raise JsonableError(_("Invalid data type for stream"))
|
raise JsonableError(_("Invalid data type for channel"))
|
||||||
|
|
||||||
|
|
||||||
def extract_private_recipients(s: str) -> Union[List[str], List[int]]:
|
def extract_private_recipients(s: str) -> Union[List[str], List[int]]:
|
||||||
|
@ -1463,8 +1463,8 @@ def send_pm_if_empty_stream(
|
||||||
"channel_id": stream_id,
|
"channel_id": stream_id,
|
||||||
}
|
}
|
||||||
content = _(
|
content = _(
|
||||||
"Your bot {bot_identity} tried to send a message to stream ID "
|
"Your bot {bot_identity} tried to send a message to channel ID "
|
||||||
"{channel_id}, but there is no stream with that ID."
|
"{channel_id}, but there is no channel with that ID."
|
||||||
).format(**arg_dict)
|
).format(**arg_dict)
|
||||||
else:
|
else:
|
||||||
assert stream_name is not None
|
assert stream_name is not None
|
||||||
|
@ -1474,8 +1474,8 @@ def send_pm_if_empty_stream(
|
||||||
"new_channel_link": "#streams/new",
|
"new_channel_link": "#streams/new",
|
||||||
}
|
}
|
||||||
content = _(
|
content = _(
|
||||||
"Your bot {bot_identity} tried to send a message to stream "
|
"Your bot {bot_identity} tried to send a message to channel "
|
||||||
"{channel_name}, but that stream does not exist. "
|
"{channel_name}, but that channel does not exist. "
|
||||||
"Click [here]({new_channel_link}) to create it."
|
"Click [here]({new_channel_link}) to create it."
|
||||||
).format(**arg_dict)
|
).format(**arg_dict)
|
||||||
else:
|
else:
|
||||||
|
@ -1487,7 +1487,7 @@ def send_pm_if_empty_stream(
|
||||||
}
|
}
|
||||||
content = _(
|
content = _(
|
||||||
"Your bot {bot_identity} tried to send a message to "
|
"Your bot {bot_identity} tried to send a message to "
|
||||||
"stream {channel_name}. The stream exists but "
|
"channel {channel_name}. The channel exists but "
|
||||||
"does not have any subscribers."
|
"does not have any subscribers."
|
||||||
).format(**arg_dict)
|
).format(**arg_dict)
|
||||||
|
|
||||||
|
|
|
@ -140,7 +140,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
msg = self.get_last_message()
|
msg = self.get_last_message()
|
||||||
expected = (
|
expected = (
|
||||||
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
||||||
"stream ID 99999, but there is no stream with that ID."
|
"channel ID 99999, but there is no channel with that ID."
|
||||||
)
|
)
|
||||||
self.assertEqual(msg.content, expected)
|
self.assertEqual(msg.content, expected)
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
msg = self.get_second_to_last_message()
|
msg = self.get_second_to_last_message()
|
||||||
expected = (
|
expected = (
|
||||||
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
||||||
"stream #**Acropolis**. The stream exists but does not have any subscribers."
|
"channel #**Acropolis**. The channel exists but does not have any subscribers."
|
||||||
)
|
)
|
||||||
self.assertEqual(msg.content, expected)
|
self.assertEqual(msg.content, expected)
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
msg = self.get_second_to_last_message()
|
msg = self.get_second_to_last_message()
|
||||||
expected = (
|
expected = (
|
||||||
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
"Your bot `whatever-bot@zulip.testserver` tried to send a message to "
|
||||||
"stream #**Acropolis**. The stream exists but does not have any subscribers."
|
"channel #**Acropolis**. The channel exists but does not have any subscribers."
|
||||||
)
|
)
|
||||||
self.assertEqual(msg.content, expected)
|
self.assertEqual(msg.content, expected)
|
||||||
|
|
||||||
|
@ -2428,13 +2428,13 @@ class ExtractTest(ZulipTestCase):
|
||||||
123,
|
123,
|
||||||
)
|
)
|
||||||
|
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid data type for stream"):
|
with self.assertRaisesRegex(JsonableError, "Invalid data type for channel"):
|
||||||
extract_stream_indicator("{}")
|
extract_stream_indicator("{}")
|
||||||
|
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid data type for stream"):
|
with self.assertRaisesRegex(JsonableError, "Invalid data type for channel"):
|
||||||
extract_stream_indicator("[{}]")
|
extract_stream_indicator("[{}]")
|
||||||
|
|
||||||
with self.assertRaisesRegex(JsonableError, "Expected exactly one stream"):
|
with self.assertRaisesRegex(JsonableError, "Expected exactly one channel"):
|
||||||
extract_stream_indicator('[1,2,"general"]')
|
extract_stream_indicator('[1,2,"general"]')
|
||||||
|
|
||||||
def test_extract_private_recipients_emails(self) -> None:
|
def test_extract_private_recipients_emails(self) -> None:
|
||||||
|
@ -3053,7 +3053,7 @@ class CheckMessageTest(ZulipTestCase):
|
||||||
|
|
||||||
new_count = message_stream_count(parent)
|
new_count = message_stream_count(parent)
|
||||||
self.assertEqual(new_count, old_count + 1)
|
self.assertEqual(new_count, old_count + 1)
|
||||||
self.assertIn("that stream does not exist.", most_recent_message(parent).content)
|
self.assertIn("that channel does not exist.", most_recent_message(parent).content)
|
||||||
|
|
||||||
# Try sending to stream that exists with no subscribers soon
|
# Try sending to stream that exists with no subscribers soon
|
||||||
# after; due to rate-limiting, this should send nothing.
|
# after; due to rate-limiting, this should send nothing.
|
||||||
|
|
|
@ -635,7 +635,7 @@ class TestOutgoingWebhookMessaging(ZulipTestCase):
|
||||||
|
|
||||||
prev_message = self.get_second_to_last_message()
|
prev_message = self.get_second_to_last_message()
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"tried to send a message to stream #**Denmark**, but that stream does not exist",
|
"tried to send a message to channel #**Denmark**, but that channel does not exist",
|
||||||
prev_message.content,
|
prev_message.content,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ class HelloWorldHookTests(WebhookTestCase):
|
||||||
self.url = self.build_webhook_url()
|
self.url = self.build_webhook_url()
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
notification_bot = get_system_bot(settings.NOTIFICATION_BOT, realm.id)
|
notification_bot = get_system_bot(settings.NOTIFICATION_BOT, realm.id)
|
||||||
expected_message = "Your bot `webhook-bot@zulip.com` tried to send a message to stream #**nonexistent**, but that stream does not exist. Click [here](#streams/new) to create it."
|
expected_message = "Your bot `webhook-bot@zulip.com` tried to send a message to channel #**nonexistent**, but that channel does not exist. Click [here](#streams/new) to create it."
|
||||||
self.send_and_test_private_message(
|
self.send_and_test_private_message(
|
||||||
"goodbye",
|
"goodbye",
|
||||||
expected_message=expected_message,
|
expected_message=expected_message,
|
||||||
|
|
Loading…
Reference in New Issue