mirror of https://github.com/zulip/zulip.git
streams: Update translated errors for stream to channel rename.
Updates translated JsonableError strings that relate to streams to use channel instead of stream. Separated from other error string updates as this is a dense area of changes for this rename. Part of stream to channel rename project.
This commit is contained in:
parent
c1f1dc4b25
commit
91ffb548cc
|
@ -306,7 +306,7 @@ class TestGetChartData(ZulipTestCase):
|
||||||
},
|
},
|
||||||
subdomain="zephyr",
|
subdomain="zephyr",
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_include_empty_subgroups(self) -> None:
|
def test_include_empty_subgroups(self) -> None:
|
||||||
FillState.objects.create(
|
FillState.objects.create(
|
||||||
|
|
|
@ -114,7 +114,7 @@ def send_user_remove_events_on_stream_deactivation(
|
||||||
def do_deactivate_stream(stream: Stream, *, acting_user: Optional[UserProfile]) -> None:
|
def do_deactivate_stream(stream: Stream, *, acting_user: Optional[UserProfile]) -> None:
|
||||||
# If the stream is already deactivated, this is a no-op
|
# If the stream is already deactivated, this is a no-op
|
||||||
if stream.deactivated is True:
|
if stream.deactivated is True:
|
||||||
raise JsonableError(_("Stream is already deactivated"))
|
raise JsonableError(_("Channel is already deactivated"))
|
||||||
|
|
||||||
# We want to mark all messages in the to-be-deactivated stream as
|
# We want to mark all messages in the to-be-deactivated stream as
|
||||||
# read for all users; otherwise they will pollute queries like
|
# read for all users; otherwise they will pollute queries like
|
||||||
|
@ -238,10 +238,10 @@ def do_unarchive_stream(
|
||||||
) -> None:
|
) -> None:
|
||||||
realm = stream.realm
|
realm = stream.realm
|
||||||
if not stream.deactivated:
|
if not stream.deactivated:
|
||||||
raise JsonableError(_("Stream is not currently deactivated"))
|
raise JsonableError(_("Channel is not currently deactivated"))
|
||||||
if Stream.objects.filter(realm=realm, name=new_name).exists():
|
if Stream.objects.filter(realm=realm, name=new_name).exists():
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Stream named {channel_name} already exists").format(channel_name=new_name)
|
_("Channel named {channel_name} already exists").format(channel_name=new_name)
|
||||||
)
|
)
|
||||||
assert stream.recipient_id is not None
|
assert stream.recipient_id is not None
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ from email.message import EmailMessage
|
||||||
from typing import Dict, List, Match, Optional, Tuple
|
from typing import Dict, List, Match, Optional, Tuple
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
|
from django.utils.translation import gettext as _
|
||||||
from typing_extensions import override
|
from typing_extensions import override
|
||||||
|
|
||||||
from zerver.actions.message_send import (
|
from zerver.actions.message_send import (
|
||||||
|
@ -205,7 +206,9 @@ def send_mm_reply_to_stream(
|
||||||
message_content=body,
|
message_content=body,
|
||||||
)
|
)
|
||||||
except JsonableError as error:
|
except JsonableError as error:
|
||||||
error_message = f"Error sending message to stream {stream.name} via message notification email reply:\n{error.msg}"
|
error_message = _(
|
||||||
|
"Error sending message to channel {channel_name} via message notification email reply:\n{error_message}"
|
||||||
|
).format(channel_name=stream.name, error_message=error.msg)
|
||||||
internal_send_private_message(
|
internal_send_private_message(
|
||||||
get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id),
|
get_system_bot(settings.NOTIFICATION_BOT, user_profile.realm_id),
|
||||||
user_profile,
|
user_profile,
|
||||||
|
|
|
@ -239,21 +239,21 @@ def check_stream_access_based_on_stream_post_policy(sender: UserProfile, stream:
|
||||||
if sender.is_realm_admin or is_cross_realm_bot_email(sender.delivery_email):
|
if sender.is_realm_admin or is_cross_realm_bot_email(sender.delivery_email):
|
||||||
pass
|
pass
|
||||||
elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_ADMINS:
|
elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_ADMINS:
|
||||||
raise JsonableError(_("Only organization administrators can send to this stream."))
|
raise JsonableError(_("Only organization administrators can send to this channel."))
|
||||||
elif (
|
elif (
|
||||||
stream.stream_post_policy == Stream.STREAM_POST_POLICY_MODERATORS
|
stream.stream_post_policy == Stream.STREAM_POST_POLICY_MODERATORS
|
||||||
and not sender.is_moderator
|
and not sender.is_moderator
|
||||||
):
|
):
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Only organization administrators and moderators can send to this stream.")
|
_("Only organization administrators and moderators can send to this channel.")
|
||||||
)
|
)
|
||||||
elif stream.stream_post_policy != Stream.STREAM_POST_POLICY_EVERYONE and sender.is_guest:
|
elif stream.stream_post_policy != Stream.STREAM_POST_POLICY_EVERYONE and sender.is_guest:
|
||||||
raise JsonableError(_("Guests cannot send to this stream."))
|
raise JsonableError(_("Guests cannot send to this channel."))
|
||||||
elif (
|
elif (
|
||||||
stream.stream_post_policy == Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS
|
stream.stream_post_policy == Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS
|
||||||
and sender.is_provisional_member
|
and sender.is_provisional_member
|
||||||
):
|
):
|
||||||
raise JsonableError(_("New members cannot send to this stream."))
|
raise JsonableError(_("New members cannot send to this channel."))
|
||||||
|
|
||||||
|
|
||||||
def access_stream_for_send_message(
|
def access_stream_for_send_message(
|
||||||
|
@ -313,22 +313,25 @@ def access_stream_for_send_message(
|
||||||
|
|
||||||
# All other cases are an error.
|
# All other cases are an error.
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Not authorized to send to stream '{channel_name}'").format(channel_name=stream.name)
|
_("Not authorized to send to channel '{channel_name}'").format(channel_name=stream.name)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def check_for_exactly_one_stream_arg(stream_id: Optional[int], stream: Optional[str]) -> None:
|
def check_for_exactly_one_stream_arg(stream_id: Optional[int], stream: Optional[str]) -> None:
|
||||||
if stream_id is None and stream is None:
|
if stream_id is None and stream is None:
|
||||||
raise JsonableError(_("Please supply 'stream'."))
|
# Uses the same translated string as RequestVariableMissingError
|
||||||
|
# with the stream_id parameter, which is the more common use case.
|
||||||
|
error = _("Missing '{var_name}' argument").format(var_name="stream_id")
|
||||||
|
raise JsonableError(error)
|
||||||
|
|
||||||
if stream_id is not None and stream is not None:
|
if stream_id is not None and stream is not None:
|
||||||
raise JsonableError(_("Please choose one: 'stream' or 'stream_id'."))
|
raise JsonableError(_("Please supply only one channel parameter: name or ID."))
|
||||||
|
|
||||||
|
|
||||||
def check_stream_access_for_delete_or_update(
|
def check_stream_access_for_delete_or_update(
|
||||||
user_profile: UserProfile, stream: Stream, sub: Optional[Subscription] = None
|
user_profile: UserProfile, stream: Stream, sub: Optional[Subscription] = None
|
||||||
) -> None:
|
) -> None:
|
||||||
error = _("Invalid stream ID")
|
error = _("Invalid channel ID")
|
||||||
if stream.realm_id != user_profile.realm_id:
|
if stream.realm_id != user_profile.realm_id:
|
||||||
raise JsonableError(error)
|
raise JsonableError(error)
|
||||||
|
|
||||||
|
@ -347,7 +350,7 @@ def access_stream_for_delete_or_update(
|
||||||
try:
|
try:
|
||||||
stream = Stream.objects.get(id=stream_id)
|
stream = Stream.objects.get(id=stream_id)
|
||||||
except Stream.DoesNotExist:
|
except Stream.DoesNotExist:
|
||||||
raise JsonableError(_("Invalid stream ID"))
|
raise JsonableError(_("Invalid channel ID"))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
sub = Subscription.objects.get(
|
sub = Subscription.objects.get(
|
||||||
|
@ -430,7 +433,7 @@ def access_stream_by_id(
|
||||||
require_active: bool = True,
|
require_active: bool = True,
|
||||||
allow_realm_admin: bool = False,
|
allow_realm_admin: bool = False,
|
||||||
) -> Tuple[Stream, Optional[Subscription]]:
|
) -> Tuple[Stream, Optional[Subscription]]:
|
||||||
error = _("Invalid stream ID")
|
error = _("Invalid channel ID")
|
||||||
try:
|
try:
|
||||||
stream = get_stream_by_id_in_realm(stream_id, user_profile.realm)
|
stream = get_stream_by_id_in_realm(stream_id, user_profile.realm)
|
||||||
except Stream.DoesNotExist:
|
except Stream.DoesNotExist:
|
||||||
|
@ -472,9 +475,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
|
||||||
check_stream_name(name)
|
check_stream_name(name)
|
||||||
try:
|
try:
|
||||||
get_stream(name, realm)
|
get_stream(name, realm)
|
||||||
raise JsonableError(
|
raise JsonableError(_("Channel name already in use."))
|
||||||
_("Stream name '{channel_name}' is already taken.").format(channel_name=name)
|
|
||||||
)
|
|
||||||
except Stream.DoesNotExist:
|
except Stream.DoesNotExist:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@ -482,7 +483,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
|
||||||
def access_stream_by_name(
|
def access_stream_by_name(
|
||||||
user_profile: UserProfile, stream_name: str, allow_realm_admin: bool = False
|
user_profile: UserProfile, stream_name: str, allow_realm_admin: bool = False
|
||||||
) -> Tuple[Stream, Optional[Subscription]]:
|
) -> Tuple[Stream, Optional[Subscription]]:
|
||||||
error = _("Invalid stream name '{channel_name}'").format(channel_name=stream_name)
|
error = _("Invalid channel name '{channel_name}'").format(channel_name=stream_name)
|
||||||
try:
|
try:
|
||||||
stream = get_realm_stream(stream_name, user_profile.realm_id)
|
stream = get_realm_stream(stream_name, user_profile.realm_id)
|
||||||
except Stream.DoesNotExist:
|
except Stream.DoesNotExist:
|
||||||
|
@ -498,7 +499,7 @@ def access_stream_by_name(
|
||||||
|
|
||||||
|
|
||||||
def access_web_public_stream(stream_id: int, realm: Realm) -> Stream:
|
def access_web_public_stream(stream_id: int, realm: Realm) -> Stream:
|
||||||
error = _("Invalid stream ID")
|
error = _("Invalid channel ID")
|
||||||
try:
|
try:
|
||||||
stream = get_stream_by_id_in_realm(stream_id, realm)
|
stream = get_stream_by_id_in_realm(stream_id, realm)
|
||||||
except Stream.DoesNotExist:
|
except Stream.DoesNotExist:
|
||||||
|
@ -602,7 +603,7 @@ def can_access_stream_history(user_profile: UserProfile, stream: Stream) -> bool
|
||||||
|
|
||||||
if stream.is_history_public_to_subscribers():
|
if stream.is_history_public_to_subscribers():
|
||||||
# In this case, we check if the user is subscribed.
|
# In this case, we check if the user is subscribed.
|
||||||
error = _("Invalid stream name '{channel_name}'").format(channel_name=stream.name)
|
error = _("Invalid channel name '{channel_name}'").format(channel_name=stream.name)
|
||||||
try:
|
try:
|
||||||
access_stream_common(user_profile, stream, error)
|
access_stream_common(user_profile, stream, error)
|
||||||
except JsonableError:
|
except JsonableError:
|
||||||
|
@ -747,11 +748,11 @@ def list_to_streams(
|
||||||
if is_default_stream and not user_profile.is_realm_admin:
|
if is_default_stream and not user_profile.is_realm_admin:
|
||||||
raise JsonableError(_("Insufficient permission"))
|
raise JsonableError(_("Insufficient permission"))
|
||||||
if invite_only and is_default_stream:
|
if invite_only and is_default_stream:
|
||||||
raise JsonableError(_("A default stream cannot be private."))
|
raise JsonableError(_("A default channel cannot be private."))
|
||||||
|
|
||||||
if not autocreate:
|
if not autocreate:
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Stream(s) ({channel_names}) do not exist").format(
|
_("Channel(s) ({channel_names}) do not exist").format(
|
||||||
channel_names=", ".join(
|
channel_names=", ".join(
|
||||||
stream_dict["name"] for stream_dict in missing_stream_dicts
|
stream_dict["name"] for stream_dict in missing_stream_dicts
|
||||||
),
|
),
|
||||||
|
@ -760,7 +761,7 @@ def list_to_streams(
|
||||||
|
|
||||||
if web_public_stream_requested:
|
if web_public_stream_requested:
|
||||||
if not user_profile.realm.web_public_streams_enabled():
|
if not user_profile.realm.web_public_streams_enabled():
|
||||||
raise JsonableError(_("Web-public streams are not enabled."))
|
raise JsonableError(_("Web-public channels are not enabled."))
|
||||||
if not user_profile.can_create_web_public_streams():
|
if not user_profile.can_create_web_public_streams():
|
||||||
# We set create_web_public_stream_policy to allow only organization owners
|
# We set create_web_public_stream_policy to allow only organization owners
|
||||||
# to create web-public streams, because of their sensitive nature.
|
# to create web-public streams, because of their sensitive nature.
|
||||||
|
@ -790,7 +791,9 @@ def access_default_stream_group_by_id(realm: Realm, group_id: int) -> DefaultStr
|
||||||
return DefaultStreamGroup.objects.get(realm=realm, id=group_id)
|
return DefaultStreamGroup.objects.get(realm=realm, id=group_id)
|
||||||
except DefaultStreamGroup.DoesNotExist:
|
except DefaultStreamGroup.DoesNotExist:
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Default stream group with id '{group_id}' does not exist.").format(group_id=group_id)
|
_("Default channel group with id '{group_id}' does not exist.").format(
|
||||||
|
group_id=group_id
|
||||||
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5139,7 +5139,7 @@ paths:
|
||||||
- example:
|
- example:
|
||||||
{
|
{
|
||||||
"code": "BAD_REQUEST",
|
"code": "BAD_REQUEST",
|
||||||
"msg": "Invalid stream name 'nonexistent'",
|
"msg": "Invalid channel name 'nonexistent'",
|
||||||
"result": "error",
|
"result": "error",
|
||||||
}
|
}
|
||||||
description: |
|
description: |
|
||||||
|
@ -6041,7 +6041,7 @@ paths:
|
||||||
- example:
|
- example:
|
||||||
{
|
{
|
||||||
"code": "BAD_REQUEST",
|
"code": "BAD_REQUEST",
|
||||||
"msg": "Private streams cannot be made default.",
|
"msg": "Private channels cannot be made default.",
|
||||||
"result": "error",
|
"result": "error",
|
||||||
}
|
}
|
||||||
description: |
|
description: |
|
||||||
|
@ -9469,7 +9469,7 @@ paths:
|
||||||
- $ref: "#/components/schemas/CodedError"
|
- $ref: "#/components/schemas/CodedError"
|
||||||
- example:
|
- example:
|
||||||
{
|
{
|
||||||
"msg": "Unable to access stream (private_stream).",
|
"msg": "Unable to access channel (private).",
|
||||||
"result": "error",
|
"result": "error",
|
||||||
"code": "BAD_REQUEST",
|
"code": "BAD_REQUEST",
|
||||||
}
|
}
|
||||||
|
@ -21281,7 +21281,7 @@ components:
|
||||||
code: {}
|
code: {}
|
||||||
example:
|
example:
|
||||||
{
|
{
|
||||||
"msg": "Invalid stream ID",
|
"msg": "Invalid channel ID",
|
||||||
"code": "BAD_REQUEST",
|
"code": "BAD_REQUEST",
|
||||||
"result": "error",
|
"result": "error",
|
||||||
}
|
}
|
||||||
|
|
|
@ -472,7 +472,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
"default_sending_stream": "Denmark",
|
"default_sending_stream": "Denmark",
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/bots", bot_info)
|
result = self.client_post("/json/bots", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'Denmark'")
|
self.assert_json_error(result, "Invalid channel name 'Denmark'")
|
||||||
|
|
||||||
def test_add_bot_with_default_events_register_stream(self) -> None:
|
def test_add_bot_with_default_events_register_stream(self) -> None:
|
||||||
bot_email = "hambot-bot@zulip.testserver"
|
bot_email = "hambot-bot@zulip.testserver"
|
||||||
|
@ -556,7 +556,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
"default_events_register_stream": "Denmark",
|
"default_events_register_stream": "Denmark",
|
||||||
}
|
}
|
||||||
result = self.client_post("/json/bots", bot_info)
|
result = self.client_post("/json/bots", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'Denmark'")
|
self.assert_json_error(result, "Invalid channel name 'Denmark'")
|
||||||
|
|
||||||
def test_add_bot_with_default_all_public_streams(self) -> None:
|
def test_add_bot_with_default_all_public_streams(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
@ -1403,7 +1403,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
}
|
}
|
||||||
email = "hambot-bot@zulip.testserver"
|
email = "hambot-bot@zulip.testserver"
|
||||||
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'Denmark'")
|
self.assert_json_error(result, "Invalid channel name 'Denmark'")
|
||||||
|
|
||||||
def test_patch_bot_to_stream_not_found(self) -> None:
|
def test_patch_bot_to_stream_not_found(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
@ -1418,7 +1418,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
}
|
}
|
||||||
email = "hambot-bot@zulip.testserver"
|
email = "hambot-bot@zulip.testserver"
|
||||||
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'missing'")
|
self.assert_json_error(result, "Invalid channel name 'missing'")
|
||||||
|
|
||||||
def test_patch_bot_events_register_stream(self) -> None:
|
def test_patch_bot_events_register_stream(self) -> None:
|
||||||
hamlet = self.example_user("hamlet")
|
hamlet = self.example_user("hamlet")
|
||||||
|
@ -1453,7 +1453,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
self.subscribe(bot_user, stream_name)
|
self.subscribe(bot_user, stream_name)
|
||||||
bot_info = dict(default_events_register_stream=stream_name)
|
bot_info = dict(default_events_register_stream=stream_name)
|
||||||
result = self.client_patch(url, bot_info)
|
result = self.client_patch(url, bot_info)
|
||||||
self.assert_json_error_contains(result, "Invalid stream name")
|
self.assert_json_error_contains(result, "Invalid channel name")
|
||||||
|
|
||||||
# Subscribing the owner allows us to patch the stream.
|
# Subscribing the owner allows us to patch the stream.
|
||||||
self.subscribe(hamlet, stream_name)
|
self.subscribe(hamlet, stream_name)
|
||||||
|
@ -1520,7 +1520,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
}
|
}
|
||||||
email = "hambot-bot@zulip.testserver"
|
email = "hambot-bot@zulip.testserver"
|
||||||
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'Denmark'")
|
self.assert_json_error(result, "Invalid channel name 'Denmark'")
|
||||||
|
|
||||||
def test_patch_bot_events_register_stream_none(self) -> None:
|
def test_patch_bot_events_register_stream_none(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
@ -1560,7 +1560,7 @@ class BotTest(ZulipTestCase, UploadSerializeMixin):
|
||||||
}
|
}
|
||||||
email = "hambot-bot@zulip.testserver"
|
email = "hambot-bot@zulip.testserver"
|
||||||
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
result = self.client_patch(f"/json/bots/{self.get_bot_user(email).id}", bot_info)
|
||||||
self.assert_json_error(result, "Invalid stream name 'missing'")
|
self.assert_json_error(result, "Invalid channel name 'missing'")
|
||||||
|
|
||||||
def test_patch_bot_default_all_public_streams_true(self) -> None:
|
def test_patch_bot_default_all_public_streams_true(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
|
|
@ -255,7 +255,7 @@ class DraftCreationTests(ZulipTestCase):
|
||||||
"timestamp": 1595479019,
|
"timestamp": 1595479019,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID")
|
self.create_and_check_drafts_for_error(draft_dicts, "Invalid channel ID")
|
||||||
|
|
||||||
# When the stream itself does not exist:
|
# When the stream itself does not exist:
|
||||||
draft_dicts = [
|
draft_dicts = [
|
||||||
|
@ -267,7 +267,7 @@ class DraftCreationTests(ZulipTestCase):
|
||||||
"timestamp": 1595479019,
|
"timestamp": 1595479019,
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
self.create_and_check_drafts_for_error(draft_dicts, "Invalid stream ID")
|
self.create_and_check_drafts_for_error(draft_dicts, "Invalid channel ID")
|
||||||
|
|
||||||
def test_create_personal_message_draft_for_non_existing_user(self) -> None:
|
def test_create_personal_message_draft_for_non_existing_user(self) -> None:
|
||||||
draft_dicts = [
|
draft_dicts = [
|
||||||
|
|
|
@ -1174,7 +1174,7 @@ class TestMissedMessageEmailMessages(ZulipTestCase):
|
||||||
|
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
message.content,
|
message.content,
|
||||||
"Error sending message to stream announce via message notification email reply:\nOnly organization administrators can send to this stream.",
|
"Error sending message to channel announce via message notification email reply:\nOnly organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
message.sender,
|
message.sender,
|
||||||
|
|
|
@ -292,7 +292,7 @@ class TestStreamHelpers(ZulipTestCase):
|
||||||
access_stream_for_send_message(cordelia, stream, forwarder_user_profile=None)
|
access_stream_for_send_message(cordelia, stream, forwarder_user_profile=None)
|
||||||
|
|
||||||
# ...but Othello can't.
|
# ...but Othello can't.
|
||||||
with self.assertRaisesRegex(JsonableError, "Not authorized to send to stream"):
|
with self.assertRaisesRegex(JsonableError, "Not authorized to send to channel"):
|
||||||
access_stream_for_send_message(othello, stream, forwarder_user_profile=None)
|
access_stream_for_send_message(othello, stream, forwarder_user_profile=None)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -590,7 +590,7 @@ class UnreadCountTests(ZulipTestCase):
|
||||||
"stream_id": invalid_stream_id,
|
"stream_id": invalid_stream_id,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_mark_all_topics_unread_with_invalid_stream_name(self) -> None:
|
def test_mark_all_topics_unread_with_invalid_stream_name(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
@ -602,7 +602,7 @@ class UnreadCountTests(ZulipTestCase):
|
||||||
"topic_name": "whatever",
|
"topic_name": "whatever",
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_mark_all_in_stream_topic_read(self) -> None:
|
def test_mark_all_in_stream_topic_read(self) -> None:
|
||||||
self.login("hamlet")
|
self.login("hamlet")
|
||||||
|
|
|
@ -394,7 +394,7 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_move_message_realm_admin_cant_move_to_private_stream_without_subscription(
|
def test_move_message_realm_admin_cant_move_to_private_stream_without_subscription(
|
||||||
self,
|
self,
|
||||||
|
@ -414,7 +414,7 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_move_message_realm_admin_cant_move_from_private_stream_without_subscription(
|
def test_move_message_realm_admin_cant_move_from_private_stream_without_subscription(
|
||||||
self,
|
self,
|
||||||
|
@ -1000,7 +1000,7 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||||
do_change_stream_post_policy(
|
do_change_stream_post_policy(
|
||||||
new_stream, Stream.STREAM_POST_POLICY_ADMINS, acting_user=user_profile
|
new_stream, Stream.STREAM_POST_POLICY_ADMINS, acting_user=user_profile
|
||||||
)
|
)
|
||||||
error_msg = "Only organization administrators can send to this stream."
|
error_msg = "Only organization administrators can send to this channel."
|
||||||
check_move_message_to_stream(UserProfile.ROLE_MODERATOR, error_msg)
|
check_move_message_to_stream(UserProfile.ROLE_MODERATOR, error_msg)
|
||||||
check_move_message_to_stream(UserProfile.ROLE_REALM_ADMINISTRATOR)
|
check_move_message_to_stream(UserProfile.ROLE_REALM_ADMINISTRATOR)
|
||||||
|
|
||||||
|
@ -1012,7 +1012,7 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||||
do_change_stream_post_policy(
|
do_change_stream_post_policy(
|
||||||
new_stream, Stream.STREAM_POST_POLICY_MODERATORS, acting_user=user_profile
|
new_stream, Stream.STREAM_POST_POLICY_MODERATORS, acting_user=user_profile
|
||||||
)
|
)
|
||||||
error_msg = "Only organization administrators and moderators can send to this stream."
|
error_msg = "Only organization administrators and moderators can send to this channel."
|
||||||
check_move_message_to_stream(UserProfile.ROLE_MEMBER, error_msg)
|
check_move_message_to_stream(UserProfile.ROLE_MEMBER, error_msg)
|
||||||
check_move_message_to_stream(UserProfile.ROLE_MODERATOR)
|
check_move_message_to_stream(UserProfile.ROLE_MODERATOR)
|
||||||
|
|
||||||
|
@ -1024,7 +1024,7 @@ class MessageMoveStreamTest(ZulipTestCase):
|
||||||
do_change_stream_post_policy(
|
do_change_stream_post_policy(
|
||||||
new_stream, Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS, acting_user=user_profile
|
new_stream, Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS, acting_user=user_profile
|
||||||
)
|
)
|
||||||
error_msg = "New members cannot send to this stream."
|
error_msg = "New members cannot send to this channel."
|
||||||
|
|
||||||
do_set_realm_property(
|
do_set_realm_property(
|
||||||
user_profile.realm, "waiting_period_threshold", 100000, acting_user=None
|
user_profile.realm, "waiting_period_threshold", 100000, acting_user=None
|
||||||
|
|
|
@ -268,7 +268,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_profile,
|
non_admin_profile,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators can send to this stream.",
|
"Only organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
non_admin_owned_bot = self.create_test_bot(
|
non_admin_owned_bot = self.create_test_bot(
|
||||||
short_name="whatever2",
|
short_name="whatever2",
|
||||||
|
@ -278,7 +278,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_owned_bot,
|
non_admin_owned_bot,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators can send to this stream.",
|
"Only organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
moderator_profile = self.example_user("shiva")
|
moderator_profile = self.example_user("shiva")
|
||||||
|
@ -288,7 +288,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
moderator_profile,
|
moderator_profile,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators can send to this stream.",
|
"Only organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
moderator_owned_bot = self.create_test_bot(
|
moderator_owned_bot = self.create_test_bot(
|
||||||
short_name="whatever3",
|
short_name="whatever3",
|
||||||
|
@ -298,7 +298,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
moderator_owned_bot,
|
moderator_owned_bot,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators can send to this stream.",
|
"Only organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Bots without owner (except cross realm bot) cannot send to announcement only streams
|
# Bots without owner (except cross realm bot) cannot send to announcement only streams
|
||||||
|
@ -313,7 +313,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
bot_without_owner,
|
bot_without_owner,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators can send to this stream.",
|
"Only organization administrators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Cross realm bots should be allowed
|
# Cross realm bots should be allowed
|
||||||
|
@ -326,7 +326,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
guest_profile = self.example_user("polonius")
|
guest_profile = self.example_user("polonius")
|
||||||
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
|
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
guest_profile, stream_name, "Only organization administrators can send to this stream."
|
guest_profile, stream_name, "Only organization administrators can send to this channel."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_sending_message_as_stream_post_policy_moderators(self) -> None:
|
def test_sending_message_as_stream_post_policy_moderators(self) -> None:
|
||||||
|
@ -370,7 +370,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_profile,
|
non_admin_profile,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators and moderators can send to this stream.",
|
"Only organization administrators and moderators can send to this channel.",
|
||||||
)
|
)
|
||||||
non_admin_owned_bot = self.create_test_bot(
|
non_admin_owned_bot = self.create_test_bot(
|
||||||
short_name="whatever3",
|
short_name="whatever3",
|
||||||
|
@ -380,7 +380,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_owned_bot,
|
non_admin_owned_bot,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators and moderators can send to this stream.",
|
"Only organization administrators and moderators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# Bots without owner (except cross realm bot) cannot send to STREAM_POST_POLICY_MODERATORS streams.
|
# Bots without owner (except cross realm bot) cannot send to STREAM_POST_POLICY_MODERATORS streams.
|
||||||
|
@ -395,7 +395,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
bot_without_owner,
|
bot_without_owner,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators and moderators can send to this stream.",
|
"Only organization administrators and moderators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
# System bots should be allowed
|
# System bots should be allowed
|
||||||
|
@ -410,7 +410,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
guest_profile,
|
guest_profile,
|
||||||
stream_name,
|
stream_name,
|
||||||
"Only organization administrators and moderators can send to this stream.",
|
"Only organization administrators and moderators can send to this channel.",
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_sending_message_as_stream_post_policy_restrict_new_members(self) -> None:
|
def test_sending_message_as_stream_post_policy_restrict_new_members(self) -> None:
|
||||||
|
@ -453,7 +453,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
# Non admins and their owned bots can send to STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS streams,
|
# Non admins and their owned bots can send to STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS streams,
|
||||||
# if the user is not a new member
|
# if the user is not a new member
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_profile, stream_name, "New members cannot send to this stream."
|
non_admin_profile, stream_name, "New members cannot send to this channel."
|
||||||
)
|
)
|
||||||
non_admin_owned_bot = self.create_test_bot(
|
non_admin_owned_bot = self.create_test_bot(
|
||||||
short_name="whatever2",
|
short_name="whatever2",
|
||||||
|
@ -461,7 +461,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
user_profile=non_admin_profile,
|
user_profile=non_admin_profile,
|
||||||
)
|
)
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
non_admin_owned_bot, stream_name, "New members cannot send to this stream."
|
non_admin_owned_bot, stream_name, "New members cannot send to this channel."
|
||||||
)
|
)
|
||||||
|
|
||||||
non_admin_profile.date_joined = timezone_now() - timedelta(days=11)
|
non_admin_profile.date_joined = timezone_now() - timedelta(days=11)
|
||||||
|
@ -485,7 +485,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
acting_user=None,
|
acting_user=None,
|
||||||
)
|
)
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
bot_without_owner, stream_name, "New members cannot send to this stream."
|
bot_without_owner, stream_name, "New members cannot send to this channel."
|
||||||
)
|
)
|
||||||
|
|
||||||
moderator_profile = self.example_user("shiva")
|
moderator_profile = self.example_user("shiva")
|
||||||
|
@ -516,7 +516,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
guest_profile = self.example_user("polonius")
|
guest_profile = self.example_user("polonius")
|
||||||
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
|
# Guests cannot send to non-STREAM_POST_POLICY_EVERYONE streams
|
||||||
self._send_and_verify_message(
|
self._send_and_verify_message(
|
||||||
guest_profile, stream_name, "Guests cannot send to this stream."
|
guest_profile, stream_name, "Guests cannot send to this channel."
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_api_message_with_default_to(self) -> None:
|
def test_api_message_with_default_to(self) -> None:
|
||||||
|
@ -1447,7 +1447,7 @@ class MessagePOSTTest(ZulipTestCase):
|
||||||
|
|
||||||
# Guest user can't send message to unsubscribed public streams
|
# Guest user can't send message to unsubscribed public streams
|
||||||
result = self.api_post(sender, "/api/v1/messages", payload)
|
result = self.api_post(sender, "/api/v1/messages", payload)
|
||||||
self.assert_json_error(result, "Not authorized to send to stream 'public stream'")
|
self.assert_json_error(result, "Not authorized to send to channel 'public stream'")
|
||||||
|
|
||||||
self.subscribe(sender, stream_name)
|
self.subscribe(sender, stream_name)
|
||||||
# Guest user can send message to subscribed public streams
|
# Guest user can send message to subscribed public streams
|
||||||
|
|
|
@ -160,7 +160,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
# non-sensible stream id
|
# non-sensible stream id
|
||||||
endpoint = "/json/users/me/9999999999/topics"
|
endpoint = "/json/users/me/9999999999/topics"
|
||||||
result = self.client_get(endpoint, {})
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# out of realm
|
# out of realm
|
||||||
bad_stream = self.make_stream(
|
bad_stream = self.make_stream(
|
||||||
|
@ -169,7 +169,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
)
|
)
|
||||||
endpoint = f"/json/users/me/{bad_stream.id}/topics"
|
endpoint = f"/json/users/me/{bad_stream.id}/topics"
|
||||||
result = self.client_get(endpoint, {})
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# private stream to which I am not subscribed
|
# private stream to which I am not subscribed
|
||||||
private_stream = self.make_stream(
|
private_stream = self.make_stream(
|
||||||
|
@ -178,7 +178,7 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
)
|
)
|
||||||
endpoint = f"/json/users/me/{private_stream.id}/topics"
|
endpoint = f"/json/users/me/{private_stream.id}/topics"
|
||||||
result = self.client_get(endpoint, {})
|
result = self.client_get(endpoint, {})
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_get_topics_web_public_stream_web_public_request(self) -> None:
|
def test_get_topics_web_public_stream_web_public_request(self) -> None:
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
|
@ -204,13 +204,13 @@ class TopicHistoryTest(ZulipTestCase):
|
||||||
stream = get_stream("Verona", self.example_user("iago").realm)
|
stream = get_stream("Verona", self.example_user("iago").realm)
|
||||||
endpoint = f"/json/users/me/{stream.id}/topics"
|
endpoint = f"/json/users/me/{stream.id}/topics"
|
||||||
result = self.client_get(endpoint)
|
result = self.client_get(endpoint)
|
||||||
self.assert_json_error(result, "Invalid stream ID", 400)
|
self.assert_json_error(result, "Invalid channel ID", 400)
|
||||||
|
|
||||||
def test_get_topics_non_existent_stream_web_public_request(self) -> None:
|
def test_get_topics_non_existent_stream_web_public_request(self) -> None:
|
||||||
non_existent_stream_id = 10000000000000000000000
|
non_existent_stream_id = 10000000000000000000000
|
||||||
endpoint = f"/json/users/me/{non_existent_stream_id}/topics"
|
endpoint = f"/json/users/me/{non_existent_stream_id}/topics"
|
||||||
result = self.client_get(endpoint)
|
result = self.client_get(endpoint)
|
||||||
self.assert_json_error(result, "Invalid stream ID", 400)
|
self.assert_json_error(result, "Invalid channel ID", 400)
|
||||||
|
|
||||||
|
|
||||||
class TopicDeleteTest(ZulipTestCase):
|
class TopicDeleteTest(ZulipTestCase):
|
||||||
|
|
|
@ -520,7 +520,7 @@ class RealmTest(ZulipTestCase):
|
||||||
new_stream_announcements_stream_id=orjson.dumps(invalid_notif_stream_id).decode()
|
new_stream_announcements_stream_id=orjson.dumps(invalid_notif_stream_id).decode()
|
||||||
)
|
)
|
||||||
result = self.client_patch("/json/realm", req)
|
result = self.client_patch("/json/realm", req)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
assert realm.new_stream_announcements_stream is not None
|
assert realm.new_stream_announcements_stream is not None
|
||||||
self.assertNotEqual(realm.new_stream_announcements_stream.id, invalid_notif_stream_id)
|
self.assertNotEqual(realm.new_stream_announcements_stream.id, invalid_notif_stream_id)
|
||||||
|
@ -605,7 +605,7 @@ class RealmTest(ZulipTestCase):
|
||||||
).decode()
|
).decode()
|
||||||
)
|
)
|
||||||
result = self.client_patch("/json/realm", req)
|
result = self.client_patch("/json/realm", req)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
assert realm.signup_announcements_stream is not None
|
assert realm.signup_announcements_stream is not None
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
|
@ -679,7 +679,7 @@ class RealmTest(ZulipTestCase):
|
||||||
).decode()
|
).decode()
|
||||||
)
|
)
|
||||||
result = self.client_patch("/json/realm", req)
|
result = self.client_patch("/json/realm", req)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
realm = get_realm("zulip")
|
realm = get_realm("zulip")
|
||||||
assert realm.zulip_update_announcements_stream is not None
|
assert realm.zulip_update_announcements_stream is not None
|
||||||
self.assertNotEqual(
|
self.assertNotEqual(
|
||||||
|
|
|
@ -425,7 +425,7 @@ class TestCreateStreams(ZulipTestCase):
|
||||||
result = self.api_post(
|
result = self.api_post(
|
||||||
user_profile, "/api/v1/users/me/subscriptions", post_data, subdomain="zulip"
|
user_profile, "/api/v1/users/me/subscriptions", post_data, subdomain="zulip"
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "A default stream cannot be private.")
|
self.assert_json_error(result, "A default channel cannot be private.")
|
||||||
|
|
||||||
def test_history_public_to_subscribers_zephyr_realm(self) -> None:
|
def test_history_public_to_subscribers_zephyr_realm(self) -> None:
|
||||||
realm = get_realm("zephyr")
|
realm = get_realm("zephyr")
|
||||||
|
@ -654,7 +654,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
}
|
}
|
||||||
stream_id = get_stream("private_stream_1", user_profile.realm).id
|
stream_id = get_stream("private_stream_1", user_profile.realm).id
|
||||||
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
stream = self.subscribe(user_profile, "private_stream_1")
|
stream = self.subscribe(user_profile, "private_stream_1")
|
||||||
self.assertFalse(stream.is_in_zephyr_realm)
|
self.assertFalse(stream.is_in_zephyr_realm)
|
||||||
|
@ -772,7 +772,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_private": orjson.dumps(True).decode(),
|
"is_private": orjson.dumps(True).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/streams/{default_stream.id}", params)
|
result = self.client_patch(f"/json/streams/{default_stream.id}", params)
|
||||||
self.assert_json_error(result, "A default stream cannot be private.")
|
self.assert_json_error(result, "A default channel cannot be private.")
|
||||||
self.assertFalse(default_stream.invite_only)
|
self.assertFalse(default_stream.invite_only)
|
||||||
|
|
||||||
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
|
do_change_user_role(user_profile, UserProfile.ROLE_MEMBER, acting_user=None)
|
||||||
|
@ -808,7 +808,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False):
|
with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False):
|
||||||
self.assertFalse(user_profile.can_create_web_public_streams())
|
self.assertFalse(user_profile.can_create_web_public_streams())
|
||||||
self.assertFalse(owner.can_create_web_public_streams())
|
self.assertFalse(owner.can_create_web_public_streams())
|
||||||
with self.assertRaisesRegex(JsonableError, "Web-public streams are not enabled."):
|
with self.assertRaisesRegex(JsonableError, "Web-public channels are not enabled."):
|
||||||
list_to_streams(
|
list_to_streams(
|
||||||
streams_raw,
|
streams_raw,
|
||||||
owner,
|
owner,
|
||||||
|
@ -981,7 +981,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)
|
do_change_user_role(user_profile, UserProfile.ROLE_REALM_OWNER, acting_user=None)
|
||||||
with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False):
|
with self.settings(WEB_PUBLIC_STREAMS_ENABLED=False):
|
||||||
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
||||||
self.assert_json_error(result, "Web-public streams are not enabled.")
|
self.assert_json_error(result, "Web-public channels are not enabled.")
|
||||||
|
|
||||||
bad_params = {
|
bad_params = {
|
||||||
"is_web_public": orjson.dumps(True).decode(),
|
"is_web_public": orjson.dumps(True).decode(),
|
||||||
|
@ -1120,7 +1120,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_private": orjson.dumps(True).decode(),
|
"is_private": orjson.dumps(True).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
result = self.client_patch(f"/json/streams/{stream_id}", params)
|
||||||
self.assert_json_error(result, "A default stream cannot be private.")
|
self.assert_json_error(result, "A default channel cannot be private.")
|
||||||
stream.refresh_from_db()
|
stream.refresh_from_db()
|
||||||
self.assertFalse(stream.invite_only)
|
self.assertFalse(stream.invite_only)
|
||||||
|
|
||||||
|
@ -1142,7 +1142,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_private": orjson.dumps(True).decode(),
|
"is_private": orjson.dumps(True).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/streams/{stream_2_id}", bad_params)
|
result = self.client_patch(f"/json/streams/{stream_2_id}", bad_params)
|
||||||
self.assert_json_error(result, "A default stream cannot be private.")
|
self.assert_json_error(result, "A default channel cannot be private.")
|
||||||
stream.refresh_from_db()
|
stream.refresh_from_db()
|
||||||
self.assertFalse(stream_2.invite_only)
|
self.assertFalse(stream_2.invite_only)
|
||||||
self.assertFalse(stream_2_id in get_default_stream_ids_for_realm(realm.id))
|
self.assertFalse(stream_2_id in get_default_stream_ids_for_realm(realm.id))
|
||||||
|
@ -1154,7 +1154,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_default_stream": orjson.dumps(True).decode(),
|
"is_default_stream": orjson.dumps(True).decode(),
|
||||||
}
|
}
|
||||||
result = self.client_patch(f"/json/streams/{private_stream_id}", params)
|
result = self.client_patch(f"/json/streams/{private_stream_id}", params)
|
||||||
self.assert_json_error(result, "A default stream cannot be private.")
|
self.assert_json_error(result, "A default channel cannot be private.")
|
||||||
self.assertFalse(private_stream_id in get_default_stream_ids_for_realm(realm.id))
|
self.assertFalse(private_stream_id in get_default_stream_ids_for_realm(realm.id))
|
||||||
|
|
||||||
params = {
|
params = {
|
||||||
|
@ -1472,14 +1472,14 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
|
|
||||||
def test_unarchive_stream_active_stream(self) -> None:
|
def test_unarchive_stream_active_stream(self) -> None:
|
||||||
stream = self.make_stream("new_stream")
|
stream = self.make_stream("new_stream")
|
||||||
with self.assertRaisesRegex(JsonableError, "Stream is not currently deactivated"):
|
with self.assertRaisesRegex(JsonableError, "Channel is not currently deactivated"):
|
||||||
do_unarchive_stream(stream, new_name="new_stream", acting_user=None)
|
do_unarchive_stream(stream, new_name="new_stream", acting_user=None)
|
||||||
|
|
||||||
def test_unarchive_stream_existing_name(self) -> None:
|
def test_unarchive_stream_existing_name(self) -> None:
|
||||||
stream = self.make_stream("new_stream")
|
stream = self.make_stream("new_stream")
|
||||||
self.make_stream("existing")
|
self.make_stream("existing")
|
||||||
do_deactivate_stream(stream, acting_user=None)
|
do_deactivate_stream(stream, acting_user=None)
|
||||||
with self.assertRaisesRegex(JsonableError, "Stream named existing already exists"):
|
with self.assertRaisesRegex(JsonableError, "Channel named existing already exists"):
|
||||||
do_unarchive_stream(stream, new_name="existing", acting_user=None)
|
do_unarchive_stream(stream, new_name="existing", acting_user=None)
|
||||||
|
|
||||||
def test_unarchive_stream(self) -> None:
|
def test_unarchive_stream(self) -> None:
|
||||||
|
@ -1558,7 +1558,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
||||||
|
|
||||||
result = self.client_delete("/json/streams/999999999")
|
result = self.client_delete("/json/streams/999999999")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_deactivate_stream_backend_requires_admin(self) -> None:
|
def test_deactivate_stream_backend_requires_admin(self) -> None:
|
||||||
user_profile = self.example_user("hamlet")
|
user_profile = self.example_user("hamlet")
|
||||||
|
@ -1621,11 +1621,11 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
||||||
|
|
||||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "stream_name1"})
|
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "stream_name1"})
|
||||||
self.assert_json_error(result, "Stream already has that name!")
|
self.assert_json_error(result, "Channel already has that name.")
|
||||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "Denmark"})
|
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "Denmark"})
|
||||||
self.assert_json_error(result, "Stream name 'Denmark' is already taken.")
|
self.assert_json_error(result, "Channel name already in use.")
|
||||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "denmark "})
|
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "denmark "})
|
||||||
self.assert_json_error(result, "Stream name 'denmark' is already taken.")
|
self.assert_json_error(result, "Channel name already in use.")
|
||||||
|
|
||||||
# Do a rename that is case-only--this should succeed.
|
# Do a rename that is case-only--this should succeed.
|
||||||
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "sTREAm_name1"})
|
result = self.client_patch(f"/json/streams/{stream.id}", {"new_name": "sTREAm_name1"})
|
||||||
|
@ -1784,7 +1784,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_private": orjson.dumps(True).decode(),
|
"is_private": orjson.dumps(True).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_non_admin_cannot_access_unsub_private_stream(self) -> None:
|
def test_non_admin_cannot_access_unsub_private_stream(self) -> None:
|
||||||
iago = self.example_user("iago")
|
iago = self.example_user("iago")
|
||||||
|
@ -1802,13 +1802,13 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
stream_id = get_stream("private_stream_1", hamlet.realm).id
|
stream_id = get_stream("private_stream_1", hamlet.realm).id
|
||||||
|
|
||||||
result = self.client_patch(f"/json/streams/{stream_id}", {"new_name": "private_stream_2"})
|
result = self.client_patch(f"/json/streams/{stream_id}", {"new_name": "private_stream_2"})
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
f"/json/streams/{stream_id}",
|
f"/json/streams/{stream_id}",
|
||||||
{"description": "new description"},
|
{"description": "new description"},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
f"/json/streams/{stream_id}",
|
f"/json/streams/{stream_id}",
|
||||||
|
@ -1816,10 +1816,10 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"is_private": orjson.dumps(True).decode(),
|
"is_private": orjson.dumps(True).decode(),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
result = self.client_delete(f"/json/streams/{stream_id}")
|
result = self.client_delete(f"/json/streams/{stream_id}")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_change_stream_description(self) -> None:
|
def test_change_stream_description(self) -> None:
|
||||||
user_profile = self.example_user("iago")
|
user_profile = self.example_user("iago")
|
||||||
|
@ -2332,7 +2332,7 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
f"/json/streams/{stream.id}",
|
f"/json/streams/{stream.id}",
|
||||||
{"can_remove_subscribers_group": orjson.dumps(moderators_system_group.id).decode()},
|
{"can_remove_subscribers_group": orjson.dumps(moderators_system_group.id).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
self.subscribe(user_profile, "stream_name2")
|
self.subscribe(user_profile, "stream_name2")
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
|
@ -2489,12 +2489,12 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
"/json/users/me/subscriptions",
|
"/json/users/me/subscriptions",
|
||||||
{"subscriptions": orjson.dumps([{"name": deactivated_stream_name}]).decode()},
|
{"subscriptions": orjson.dumps([{"name": deactivated_stream_name}]).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, f"Unable to access stream ({deactivated_stream_name}).")
|
self.assert_json_error(result, f"Unable to access channel ({deactivated_stream_name}).")
|
||||||
|
|
||||||
# You cannot re-archive the stream
|
# You cannot re-archive the stream
|
||||||
with self.capture_send_event_calls(expected_num_events=0) as events:
|
with self.capture_send_event_calls(expected_num_events=0) as events:
|
||||||
result = self.client_delete("/json/streams/" + str(stream_id))
|
result = self.client_delete("/json/streams/" + str(stream_id))
|
||||||
self.assert_json_error(result, "Stream is already deactivated")
|
self.assert_json_error(result, "Channel is already deactivated")
|
||||||
|
|
||||||
def test_you_must_be_realm_admin(self) -> None:
|
def test_you_must_be_realm_admin(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -2507,13 +2507,13 @@ class StreamAdminTest(ZulipTestCase):
|
||||||
stream = self.make_stream("other_realm_stream", realm=other_realm)
|
stream = self.make_stream("other_realm_stream", realm=other_realm)
|
||||||
|
|
||||||
result = self.client_delete("/json/streams/" + str(stream.id))
|
result = self.client_delete("/json/streams/" + str(stream.id))
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# Even becoming a realm admin doesn't help us for an out-of-realm
|
# Even becoming a realm admin doesn't help us for an out-of-realm
|
||||||
# stream.
|
# stream.
|
||||||
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
do_change_user_role(user_profile, UserProfile.ROLE_REALM_ADMINISTRATOR, acting_user=None)
|
||||||
result = self.client_delete("/json/streams/" + str(stream.id))
|
result = self.client_delete("/json/streams/" + str(stream.id))
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_delete_public_stream(self) -> None:
|
def test_delete_public_stream(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -2964,12 +2964,12 @@ class DefaultStreamTest(ZulipTestCase):
|
||||||
stream = self.make_stream(stream_name, invite_only=True)
|
stream = self.make_stream(stream_name, invite_only=True)
|
||||||
self.subscribe(self.example_user("iago"), stream_name)
|
self.subscribe(self.example_user("iago"), stream_name)
|
||||||
result = self.client_post("/json/default_streams", dict(stream_id=stream.id))
|
result = self.client_post("/json/default_streams", dict(stream_id=stream.id))
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# Test admin can't add subscribed private stream also.
|
# Test admin can't add subscribed private stream also.
|
||||||
self.subscribe(user_profile, stream_name)
|
self.subscribe(user_profile, stream_name)
|
||||||
result = self.client_post("/json/default_streams", dict(stream_id=stream.id))
|
result = self.client_post("/json/default_streams", dict(stream_id=stream.id))
|
||||||
self.assert_json_error(result, "Private streams cannot be made default.")
|
self.assert_json_error(result, "Private channels cannot be made default.")
|
||||||
|
|
||||||
def test_guest_user_access_to_streams(self) -> None:
|
def test_guest_user_access_to_streams(self) -> None:
|
||||||
user_profile = self.example_user("polonius")
|
user_profile = self.example_user("polonius")
|
||||||
|
@ -3145,7 +3145,7 @@ class DefaultStreamGroupTest(ZulipTestCase):
|
||||||
"/json/default_stream_groups/12345/streams",
|
"/json/default_stream_groups/12345/streams",
|
||||||
{"op": "add", "stream_names": orjson.dumps(new_stream_names).decode()},
|
{"op": "add", "stream_names": orjson.dumps(new_stream_names).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Default stream group with id '12345' does not exist.")
|
self.assert_json_error(result, "Default channel group with id '12345' does not exist.")
|
||||||
|
|
||||||
result = self.client_patch(f"/json/default_stream_groups/{group_id}/streams", {"op": "add"})
|
result = self.client_patch(f"/json/default_stream_groups/{group_id}/streams", {"op": "add"})
|
||||||
self.assert_json_error(result, "Missing 'stream_names' argument")
|
self.assert_json_error(result, "Missing 'stream_names' argument")
|
||||||
|
@ -3183,13 +3183,13 @@ class DefaultStreamGroupTest(ZulipTestCase):
|
||||||
"/json/default_stream_groups/12345/streams",
|
"/json/default_stream_groups/12345/streams",
|
||||||
{"op": "remove", "stream_names": orjson.dumps(new_stream_names).decode()},
|
{"op": "remove", "stream_names": orjson.dumps(new_stream_names).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Default stream group with id '12345' does not exist.")
|
self.assert_json_error(result, "Default channel group with id '12345' does not exist.")
|
||||||
|
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
f"/json/default_stream_groups/{group_id}/streams",
|
f"/json/default_stream_groups/{group_id}/streams",
|
||||||
{"op": "remove", "stream_names": orjson.dumps(["random stream name"]).decode()},
|
{"op": "remove", "stream_names": orjson.dumps(["random stream name"]).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream name 'random stream name'")
|
self.assert_json_error(result, "Invalid channel name 'random stream name'")
|
||||||
|
|
||||||
streams.remove(new_streams[0])
|
streams.remove(new_streams[0])
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
|
@ -3220,7 +3220,7 @@ class DefaultStreamGroupTest(ZulipTestCase):
|
||||||
"/json/default_stream_groups/12345",
|
"/json/default_stream_groups/12345",
|
||||||
{"new_description": new_description},
|
{"new_description": new_description},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Default stream group with id '12345' does not exist.")
|
self.assert_json_error(result, "Default channel group with id '12345' does not exist.")
|
||||||
|
|
||||||
result = self.client_patch(
|
result = self.client_patch(
|
||||||
f"/json/default_stream_groups/{group_id}",
|
f"/json/default_stream_groups/{group_id}",
|
||||||
|
@ -3266,7 +3266,9 @@ class DefaultStreamGroupTest(ZulipTestCase):
|
||||||
self.assert_length(default_stream_groups, 0)
|
self.assert_length(default_stream_groups, 0)
|
||||||
|
|
||||||
result = self.client_delete(f"/json/default_stream_groups/{group_id}")
|
result = self.client_delete(f"/json/default_stream_groups/{group_id}")
|
||||||
self.assert_json_error(result, f"Default stream group with id '{group_id}' does not exist.")
|
self.assert_json_error(
|
||||||
|
result, f"Default channel group with id '{group_id}' does not exist."
|
||||||
|
)
|
||||||
|
|
||||||
def test_invalid_default_stream_group_name(self) -> None:
|
def test_invalid_default_stream_group_name(self) -> None:
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
@ -3420,7 +3422,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
result, "Not subscribed to stream id {}".format(not_subbed[0]["stream_id"])
|
result, "Not subscribed to channel ID {}".format(not_subbed[0]["stream_id"])
|
||||||
)
|
)
|
||||||
|
|
||||||
def test_set_color_missing_color(self) -> None:
|
def test_set_color_missing_color(self) -> None:
|
||||||
|
@ -3720,7 +3722,7 @@ class SubscriptionPropertiesTest(ZulipTestCase):
|
||||||
).decode()
|
).decode()
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_set_invalid_property(self) -> None:
|
def test_set_invalid_property(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -3858,7 +3860,7 @@ class SubscriptionRestApiTest(ZulipTestCase):
|
||||||
"/api/v1/users/me/subscriptions/121",
|
"/api/v1/users/me/subscriptions/121",
|
||||||
{"property": "is_muted", "value": "somevalue"},
|
{"property": "is_muted", "value": "somevalue"},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_bad_add_parameters(self) -> None:
|
def test_bad_add_parameters(self) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
|
@ -5081,7 +5083,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||||
)
|
)
|
||||||
self.assert_json_error(
|
self.assert_json_error(
|
||||||
result,
|
result,
|
||||||
"You can only invite other Zephyr mirroring users to private streams.",
|
"You can only invite other Zephyr mirroring users to private channels.",
|
||||||
status_code=400,
|
status_code=400,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -5304,7 +5306,7 @@ class SubscriptionAPITest(ZulipTestCase):
|
||||||
"/json/users/me/subscriptions",
|
"/json/users/me/subscriptions",
|
||||||
{"subscriptions": orjson.dumps(streams_to_remove).decode()},
|
{"subscriptions": orjson.dumps(streams_to_remove).decode()},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, f"Stream(s) ({random_streams[0]}) do not exist")
|
self.assert_json_error(result, f"Channel(s) ({random_streams[0]}) do not exist")
|
||||||
|
|
||||||
def get_subscription(self, user_profile: UserProfile, stream_name: str) -> Subscription:
|
def get_subscription(self, user_profile: UserProfile, stream_name: str) -> Subscription:
|
||||||
stream = get_stream(stream_name, self.test_realm)
|
stream = get_stream(stream_name, self.test_realm)
|
||||||
|
@ -5675,14 +5677,14 @@ class GetStreamsTest(ZulipTestCase):
|
||||||
self.assertEqual(json["stream"]["stream_id"], denmark_stream.id)
|
self.assertEqual(json["stream"]["stream_id"], denmark_stream.id)
|
||||||
|
|
||||||
result = self.client_get("/json/streams/9999")
|
result = self.client_get("/json/streams/9999")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
private_stream = self.make_stream("private_stream", invite_only=True)
|
private_stream = self.make_stream("private_stream", invite_only=True)
|
||||||
self.subscribe(self.example_user("cordelia"), "private_stream")
|
self.subscribe(self.example_user("cordelia"), "private_stream")
|
||||||
|
|
||||||
# Non-admins cannot access unsubscribed private streams.
|
# Non-admins cannot access unsubscribed private streams.
|
||||||
result = self.client_get(f"/json/streams/{private_stream.id}")
|
result = self.client_get(f"/json/streams/{private_stream.id}")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
result = self.client_get(f"/json/streams/{private_stream.id}")
|
result = self.client_get(f"/json/streams/{private_stream.id}")
|
||||||
|
@ -5712,7 +5714,7 @@ class GetStreamsTest(ZulipTestCase):
|
||||||
|
|
||||||
self.login("polonius")
|
self.login("polonius")
|
||||||
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
self.subscribe(polonius, "Denmark")
|
self.subscribe(polonius, "Denmark")
|
||||||
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
||||||
|
@ -5733,7 +5735,7 @@ class GetStreamsTest(ZulipTestCase):
|
||||||
|
|
||||||
self.unsubscribe(hamlet, "Denmark")
|
self.unsubscribe(hamlet, "Denmark")
|
||||||
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
||||||
|
@ -5742,7 +5744,7 @@ class GetStreamsTest(ZulipTestCase):
|
||||||
|
|
||||||
self.unsubscribe(iago, "Denmark")
|
self.unsubscribe(iago, "Denmark")
|
||||||
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
result = self.client_get(f"/json/streams/{denmark_stream.id}/email_address")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
|
|
||||||
class StreamIdTest(ZulipTestCase):
|
class StreamIdTest(ZulipTestCase):
|
||||||
|
@ -5758,7 +5760,7 @@ class StreamIdTest(ZulipTestCase):
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
self.login_user(user)
|
self.login_user(user)
|
||||||
result = self.client_get("/json/get_stream_id", {"stream": "wrongname"})
|
result = self.client_get("/json/get_stream_id", {"stream": "wrongname"})
|
||||||
self.assert_json_error(result, "Invalid stream name 'wrongname'")
|
self.assert_json_error(result, "Invalid channel name 'wrongname'")
|
||||||
|
|
||||||
|
|
||||||
class InviteOnlyStreamTest(ZulipTestCase):
|
class InviteOnlyStreamTest(ZulipTestCase):
|
||||||
|
@ -5816,7 +5818,7 @@ class InviteOnlyStreamTest(ZulipTestCase):
|
||||||
# Subscribing oneself to an invite-only stream is not allowed
|
# Subscribing oneself to an invite-only stream is not allowed
|
||||||
self.login_user(othello)
|
self.login_user(othello)
|
||||||
result = self.common_subscribe_to_streams(othello, [stream_name], allow_fail=True)
|
result = self.common_subscribe_to_streams(othello, [stream_name], allow_fail=True)
|
||||||
self.assert_json_error(result, "Unable to access stream (Saxony).")
|
self.assert_json_error(result, "Unable to access channel (Saxony).")
|
||||||
|
|
||||||
# authorization_errors_fatal=False works
|
# authorization_errors_fatal=False works
|
||||||
self.login_user(othello)
|
self.login_user(othello)
|
||||||
|
@ -6334,7 +6336,7 @@ class GetSubscribersTest(ZulipTestCase):
|
||||||
# Verify another user can't get the data.
|
# Verify another user can't get the data.
|
||||||
self.login("cordelia")
|
self.login("cordelia")
|
||||||
result = self.client_get(f"/json/streams/{stream_id}/members")
|
result = self.client_get(f"/json/streams/{stream_id}/members")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# But an organization administrator can
|
# But an organization administrator can
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
@ -6347,7 +6349,7 @@ class GetSubscribersTest(ZulipTestCase):
|
||||||
"""
|
"""
|
||||||
stream_id = 99999999
|
stream_id = 99999999
|
||||||
result = self.client_get(f"/json/streams/{stream_id}/members")
|
result = self.client_get(f"/json/streams/{stream_id}/members")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_json_get_subscribers(self) -> None:
|
def test_json_get_subscribers(self) -> None:
|
||||||
"""
|
"""
|
||||||
|
@ -6402,7 +6404,7 @@ class GetSubscribersTest(ZulipTestCase):
|
||||||
# Try to fetch the subscriber list as a non-member & non-realm-admin-user.
|
# Try to fetch the subscriber list as a non-member & non-realm-admin-user.
|
||||||
stream_id = get_stream(stream_name, user_profile.realm).id
|
stream_id = get_stream(stream_name, user_profile.realm).id
|
||||||
result = self.make_subscriber_request(stream_id, user=user_profile)
|
result = self.make_subscriber_request(stream_id, user=user_profile)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# Try to fetch the subscriber list as a non-member & realm-admin-user.
|
# Try to fetch the subscriber list as a non-member & realm-admin-user.
|
||||||
self.login("iago")
|
self.login("iago")
|
||||||
|
@ -6425,9 +6427,9 @@ class AccessStreamTest(ZulipTestCase):
|
||||||
othello = self.example_user("othello")
|
othello = self.example_user("othello")
|
||||||
|
|
||||||
# Nobody can access a stream that doesn't exist
|
# Nobody can access a stream that doesn't exist
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(hamlet, 501232)
|
access_stream_by_id(hamlet, 501232)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'invalid stream'"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel name 'invalid stream'"):
|
||||||
access_stream_by_name(hamlet, "invalid stream")
|
access_stream_by_name(hamlet, "invalid stream")
|
||||||
|
|
||||||
# Hamlet can access the private stream
|
# Hamlet can access the private stream
|
||||||
|
@ -6440,9 +6442,9 @@ class AccessStreamTest(ZulipTestCase):
|
||||||
self.assertEqual(sub_ret, sub_ret2)
|
self.assertEqual(sub_ret, sub_ret2)
|
||||||
|
|
||||||
# Othello cannot access the private stream
|
# Othello cannot access the private stream
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(othello, stream.id)
|
access_stream_by_id(othello, stream.id)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel name 'new_private_stream'"):
|
||||||
access_stream_by_name(othello, stream.name)
|
access_stream_by_name(othello, stream.name)
|
||||||
|
|
||||||
# Both Othello and Hamlet can access a public stream that only
|
# Both Othello and Hamlet can access a public stream that only
|
||||||
|
@ -6459,19 +6461,19 @@ class AccessStreamTest(ZulipTestCase):
|
||||||
mit_realm = get_realm("zephyr")
|
mit_realm = get_realm("zephyr")
|
||||||
mit_stream = ensure_stream(mit_realm, "mit_stream", invite_only=False, acting_user=None)
|
mit_stream = ensure_stream(mit_realm, "mit_stream", invite_only=False, acting_user=None)
|
||||||
sipbtest = self.mit_user("sipbtest")
|
sipbtest = self.mit_user("sipbtest")
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(hamlet, mit_stream.id)
|
access_stream_by_id(hamlet, mit_stream.id)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel name 'mit_stream'"):
|
||||||
access_stream_by_name(hamlet, mit_stream.name)
|
access_stream_by_name(hamlet, mit_stream.name)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(sipbtest, stream.id)
|
access_stream_by_id(sipbtest, stream.id)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'new_private_stream'"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel name 'new_private_stream'"):
|
||||||
access_stream_by_name(sipbtest, stream.name)
|
access_stream_by_name(sipbtest, stream.name)
|
||||||
|
|
||||||
# MIT realm users cannot access even public streams in their realm
|
# MIT realm users cannot access even public streams in their realm
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(sipbtest, mit_stream.id)
|
access_stream_by_id(sipbtest, mit_stream.id)
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream name 'mit_stream'"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel name 'mit_stream'"):
|
||||||
access_stream_by_name(sipbtest, mit_stream.name)
|
access_stream_by_name(sipbtest, mit_stream.name)
|
||||||
|
|
||||||
# But they can access streams they are subscribed to
|
# But they can access streams they are subscribed to
|
||||||
|
@ -6486,7 +6488,7 @@ class AccessStreamTest(ZulipTestCase):
|
||||||
stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=False)
|
stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=False)
|
||||||
|
|
||||||
# Guest user don't have access to unsubscribed public streams
|
# Guest user don't have access to unsubscribed public streams
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(guest_user_profile, stream.id)
|
access_stream_by_id(guest_user_profile, stream.id)
|
||||||
|
|
||||||
# Guest user have access to subscribed public streams
|
# Guest user have access to subscribed public streams
|
||||||
|
@ -6499,7 +6501,7 @@ class AccessStreamTest(ZulipTestCase):
|
||||||
stream_name = "private_stream_1"
|
stream_name = "private_stream_1"
|
||||||
stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=True)
|
stream = self.make_stream(stream_name, guest_user_profile.realm, invite_only=True)
|
||||||
# Obviously, a guest user doesn't have access to unsubscribed private streams either
|
# Obviously, a guest user doesn't have access to unsubscribed private streams either
|
||||||
with self.assertRaisesRegex(JsonableError, "Invalid stream ID"):
|
with self.assertRaisesRegex(JsonableError, "Invalid channel ID"):
|
||||||
access_stream_by_id(guest_user_profile, stream.id)
|
access_stream_by_id(guest_user_profile, stream.id)
|
||||||
|
|
||||||
# Guest user have access to subscribed private streams
|
# Guest user have access to subscribed private streams
|
||||||
|
|
|
@ -145,7 +145,7 @@ class TypingValidateStreamIdTopicArgumentsTest(ZulipTestCase):
|
||||||
"topic": topic_name,
|
"topic": topic_name,
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
|
|
||||||
class TypingHappyPathTestDirectMessages(ZulipTestCase):
|
class TypingHappyPathTestDirectMessages(ZulipTestCase):
|
||||||
|
|
|
@ -190,15 +190,15 @@ class MutedTopicsTestsDeprecated(ZulipTestCase):
|
||||||
|
|
||||||
data = {"stream_id": 999999999, "topic": "Verona3", "op": "add"}
|
data = {"stream_id": 999999999, "topic": "Verona3", "op": "add"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
data = {"topic": "Verona3", "op": "add"}
|
data = {"topic": "Verona3", "op": "add"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
self.assert_json_error(result, "Please supply 'stream'.")
|
self.assert_json_error(result, "Missing 'stream_id' argument")
|
||||||
|
|
||||||
data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "add"}
|
data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "add"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
self.assert_json_error(result, "Please choose one: 'stream' or 'stream_id'.")
|
self.assert_json_error(result, "Please supply only one channel parameter: name or ID.")
|
||||||
|
|
||||||
data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "add"}
|
data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "add"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
|
@ -234,11 +234,11 @@ class MutedTopicsTestsDeprecated(ZulipTestCase):
|
||||||
|
|
||||||
data = {"topic": "Verona3", "op": "remove"}
|
data = {"topic": "Verona3", "op": "remove"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
self.assert_json_error(result, "Please supply 'stream'.")
|
self.assert_json_error(result, "Missing 'stream_id' argument")
|
||||||
|
|
||||||
data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "remove"}
|
data = {"stream": stream.name, "stream_id": stream.id, "topic": "Verona3", "op": "remove"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
self.assert_json_error(result, "Please choose one: 'stream' or 'stream_id'.")
|
self.assert_json_error(result, "Please supply only one channel parameter: name or ID.")
|
||||||
|
|
||||||
data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "remove"}
|
data = {"stream_id": stream.id, "topic": "a" * (MAX_TOPIC_NAME_LENGTH + 1), "op": "remove"}
|
||||||
result = self.api_patch(user, url, data)
|
result = self.api_patch(user, url, data)
|
||||||
|
@ -447,7 +447,7 @@ class MutedTopicsTests(ZulipTestCase):
|
||||||
"visibility_policy": UserTopic.VisibilityPolicy.MUTED,
|
"visibility_policy": UserTopic.VisibilityPolicy.MUTED,
|
||||||
}
|
}
|
||||||
result = self.api_post(user, url, data)
|
result = self.api_post(user, url, data)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
stream = get_stream("Verona", user.realm)
|
stream = get_stream("Verona", user.realm)
|
||||||
data = {
|
data = {
|
||||||
|
@ -472,7 +472,7 @@ class MutedTopicsTests(ZulipTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self.api_post(user, url, data)
|
result = self.api_post(user, url, data)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
stream = get_stream("Verona", user.realm)
|
stream = get_stream("Verona", user.realm)
|
||||||
data = {
|
data = {
|
||||||
|
@ -663,7 +663,7 @@ class UnmutedTopicsTests(ZulipTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self.api_post(user, url, data)
|
result = self.api_post(user, url, data)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
def test_unmuted_topic_remove_invalid(self) -> None:
|
def test_unmuted_topic_remove_invalid(self) -> None:
|
||||||
user = self.example_user("hamlet")
|
user = self.example_user("hamlet")
|
||||||
|
@ -677,7 +677,7 @@ class UnmutedTopicsTests(ZulipTestCase):
|
||||||
}
|
}
|
||||||
|
|
||||||
result = self.api_post(user, url, data)
|
result = self.api_post(user, url, data)
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
|
|
||||||
class AutomaticallyFollowTopicsTests(ZulipTestCase):
|
class AutomaticallyFollowTopicsTests(ZulipTestCase):
|
||||||
|
|
|
@ -1492,7 +1492,7 @@ class UserProfileTest(ZulipTestCase):
|
||||||
|
|
||||||
# Invalid stream ID.
|
# Invalid stream ID.
|
||||||
result = self.client_get(f"/json/users/{iago.id}/subscriptions/25")
|
result = self.client_get(f"/json/users/{iago.id}/subscriptions/25")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
result = orjson.loads(
|
result = orjson.loads(
|
||||||
self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}").content
|
self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}").content
|
||||||
|
@ -1541,7 +1541,7 @@ class UserProfileTest(ZulipTestCase):
|
||||||
# Unsubscribed non-admins cannot check subscription status in a private stream.
|
# Unsubscribed non-admins cannot check subscription status in a private stream.
|
||||||
self.login("shiva")
|
self.login("shiva")
|
||||||
result = self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}")
|
result = self.client_get(f"/json/users/{iago.id}/subscriptions/{stream.id}")
|
||||||
self.assert_json_error(result, "Invalid stream ID")
|
self.assert_json_error(result, "Invalid channel ID")
|
||||||
|
|
||||||
# Subscribed non-admins can check subscription status in a private stream
|
# Subscribed non-admins can check subscription status in a private stream
|
||||||
self.subscribe(self.example_user("shiva"), stream.name)
|
self.subscribe(self.example_user("shiva"), stream.name)
|
||||||
|
|
|
@ -130,7 +130,7 @@ def add_default_stream(
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
||||||
if stream.invite_only:
|
if stream.invite_only:
|
||||||
raise JsonableError(_("Private streams cannot be made default."))
|
raise JsonableError(_("Private channels cannot be made default."))
|
||||||
do_add_default_stream(stream)
|
do_add_default_stream(stream)
|
||||||
return json_success(request)
|
return json_success(request)
|
||||||
|
|
||||||
|
@ -296,7 +296,7 @@ def update_stream_backend(
|
||||||
|
|
||||||
# Ensure that a stream cannot be both a default stream for new users and private
|
# Ensure that a stream cannot be both a default stream for new users and private
|
||||||
if proposed_is_private and proposed_is_default_stream:
|
if proposed_is_private and proposed_is_default_stream:
|
||||||
raise JsonableError(_("A default stream cannot be private."))
|
raise JsonableError(_("A default channel cannot be private."))
|
||||||
|
|
||||||
if is_private is not None:
|
if is_private is not None:
|
||||||
# We require even realm administrators to be actually
|
# We require even realm administrators to be actually
|
||||||
|
@ -309,7 +309,7 @@ def update_stream_backend(
|
||||||
# web-public, we don't use an "is not None" check.
|
# web-public, we don't use an "is not None" check.
|
||||||
if is_web_public:
|
if is_web_public:
|
||||||
if not user_profile.realm.web_public_streams_enabled():
|
if not user_profile.realm.web_public_streams_enabled():
|
||||||
raise JsonableError(_("Web-public streams are not enabled."))
|
raise JsonableError(_("Web-public channels are not enabled."))
|
||||||
if not user_profile.can_create_web_public_streams():
|
if not user_profile.can_create_web_public_streams():
|
||||||
raise JsonableError(_("Insufficient permission"))
|
raise JsonableError(_("Insufficient permission"))
|
||||||
|
|
||||||
|
@ -351,7 +351,7 @@ def update_stream_backend(
|
||||||
if new_name is not None:
|
if new_name is not None:
|
||||||
new_name = new_name.strip()
|
new_name = new_name.strip()
|
||||||
if stream.name == new_name:
|
if stream.name == new_name:
|
||||||
raise JsonableError(_("Stream already has that name!"))
|
raise JsonableError(_("Channel already has that name."))
|
||||||
if stream.name.lower() != new_name.lower():
|
if stream.name.lower() != new_name.lower():
|
||||||
# Check that the stream name is available (unless we are
|
# Check that the stream name is available (unless we are
|
||||||
# are only changing the casing of the stream name).
|
# are only changing the casing of the stream name).
|
||||||
|
@ -380,7 +380,7 @@ def update_stream_backend(
|
||||||
] != getattr(stream, setting_group_id_name):
|
] != getattr(stream, setting_group_id_name):
|
||||||
if sub is None and stream.invite_only:
|
if sub is None and stream.invite_only:
|
||||||
# Admins cannot change this setting for unsubscribed private streams.
|
# Admins cannot change this setting for unsubscribed private streams.
|
||||||
raise JsonableError(_("Invalid stream ID"))
|
raise JsonableError(_("Invalid channel ID"))
|
||||||
|
|
||||||
user_group_id = request_settings_dict[setting_group_id_name]
|
user_group_id = request_settings_dict[setting_group_id_name]
|
||||||
user_group = access_user_group_for_setting(
|
user_group = access_user_group_for_setting(
|
||||||
|
@ -636,7 +636,7 @@ def add_subscriptions_backend(
|
||||||
)
|
)
|
||||||
if len(unauthorized_streams) > 0 and authorization_errors_fatal:
|
if len(unauthorized_streams) > 0 and authorization_errors_fatal:
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Unable to access stream ({channel_name}).").format(
|
_("Unable to access channel ({channel_name}).").format(
|
||||||
channel_name=unauthorized_streams[0].name,
|
channel_name=unauthorized_streams[0].name,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -649,7 +649,7 @@ def add_subscriptions_backend(
|
||||||
and not all(stream.invite_only for stream in streams)
|
and not all(stream.invite_only for stream in streams)
|
||||||
):
|
):
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("You can only invite other Zephyr mirroring users to private streams.")
|
_("You can only invite other Zephyr mirroring users to private channels.")
|
||||||
)
|
)
|
||||||
|
|
||||||
if is_default_stream:
|
if is_default_stream:
|
||||||
|
@ -1016,7 +1016,7 @@ def update_subscription_properties_backend(
|
||||||
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
||||||
if sub is None:
|
if sub is None:
|
||||||
raise JsonableError(
|
raise JsonableError(
|
||||||
_("Not subscribed to stream id {channel_id}").format(channel_id=stream_id)
|
_("Not subscribed to channel ID {channel_id}").format(channel_id=stream_id)
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -99,7 +99,7 @@ def update_user_topic(
|
||||||
visibility_policy: int = REQ(json_validator=check_int_in(UserTopic.VisibilityPolicy.values)),
|
visibility_policy: int = REQ(json_validator=check_int_in(UserTopic.VisibilityPolicy.values)),
|
||||||
) -> HttpResponse:
|
) -> HttpResponse:
|
||||||
if visibility_policy == UserTopic.VisibilityPolicy.INHERIT:
|
if visibility_policy == UserTopic.VisibilityPolicy.INHERIT:
|
||||||
error = _("Invalid stream ID")
|
error = _("Invalid channel ID")
|
||||||
stream = access_stream_to_remove_visibility_policy_by_id(user_profile, stream_id, error)
|
stream = access_stream_to_remove_visibility_policy_by_id(user_profile, stream_id, error)
|
||||||
else:
|
else:
|
||||||
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
||||||
|
|
Loading…
Reference in New Issue