mirror of https://github.com/zulip/zulip.git
refactor: Remove recipient from access_stream_by_name.
This commit is contained in:
parent
a51b483f1a
commit
e1bcf6124f
|
@ -361,7 +361,7 @@ def check_stream_name_available(realm: Realm, name: str) -> None:
|
|||
|
||||
def access_stream_by_name(user_profile: UserProfile,
|
||||
stream_name: str,
|
||||
allow_realm_admin: bool=False) -> Tuple[Stream, Recipient, Optional[Subscription]]:
|
||||
allow_realm_admin: bool=False) -> Tuple[Stream, Optional[Subscription]]:
|
||||
error = _("Invalid stream name '{}'").format(stream_name)
|
||||
try:
|
||||
stream = get_realm_stream(stream_name, user_profile.realm_id)
|
||||
|
@ -374,7 +374,7 @@ def access_stream_by_name(user_profile: UserProfile,
|
|||
error,
|
||||
allow_realm_admin=allow_realm_admin,
|
||||
)
|
||||
return (stream, stream.recipient, sub)
|
||||
return (stream, sub)
|
||||
|
||||
def access_web_public_stream(stream_id: int, realm: Realm) -> Stream:
|
||||
error = _("Invalid stream id")
|
||||
|
|
|
@ -4597,7 +4597,7 @@ class AccessStreamTest(ZulipTestCase):
|
|||
self.assertEqual(stream.id, stream_ret.id)
|
||||
assert sub_ret is not None
|
||||
self.assertEqual(sub_ret.recipient.type_id, stream.id)
|
||||
(stream_ret2, rec_ret2, sub_ret2) = access_stream_by_name(hamlet, stream.name)
|
||||
(stream_ret2, sub_ret2) = access_stream_by_name(hamlet, stream.name)
|
||||
self.assertEqual(stream_ret.id, stream_ret2.id)
|
||||
self.assertEqual(sub_ret, sub_ret2)
|
||||
|
||||
|
|
|
@ -78,7 +78,7 @@ def detect_narrowed_window(request: HttpRequest,
|
|||
try:
|
||||
# TODO: We should support stream IDs and PMs here as well.
|
||||
narrow_stream_name = request.GET.get("stream")
|
||||
(narrow_stream, ignored_rec, ignored_sub) = access_stream_by_name(
|
||||
(narrow_stream, ignored_sub) = access_stream_by_name(
|
||||
user_profile, narrow_stream_name)
|
||||
narrow = [["stream", narrow_stream.name]]
|
||||
except Exception:
|
||||
|
|
|
@ -26,7 +26,7 @@ def mute_topic(user_profile: UserProfile,
|
|||
topic_name: str,
|
||||
date_muted: datetime.datetime) -> HttpResponse:
|
||||
if stream_name is not None:
|
||||
(stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
else:
|
||||
assert stream_id is not None
|
||||
(stream, sub) = access_stream_by_id(user_profile, stream_id)
|
||||
|
|
|
@ -163,7 +163,7 @@ def create_default_stream_group(request: HttpRequest, user_profile: UserProfile,
|
|||
stream_names: List[str]=REQ(validator=check_list(check_string))) -> None:
|
||||
streams = []
|
||||
for stream_name in stream_names:
|
||||
(stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
streams.append(stream)
|
||||
do_create_default_stream_group(user_profile.realm, group_name, description, streams)
|
||||
return json_success()
|
||||
|
@ -193,7 +193,7 @@ def update_default_stream_group_streams(request: HttpRequest, user_profile: User
|
|||
group = access_default_stream_group_by_id(user_profile.realm, group_id)
|
||||
streams = []
|
||||
for stream_name in stream_names:
|
||||
(stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
streams.append(stream)
|
||||
|
||||
if op == 'add':
|
||||
|
@ -711,7 +711,7 @@ def json_stream_exists(request: HttpRequest, user_profile: UserProfile, stream_n
|
|||
check_stream_name(stream_name)
|
||||
|
||||
try:
|
||||
(stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
except JsonableError as e:
|
||||
return json_error(e.msg, status=404)
|
||||
|
||||
|
@ -732,7 +732,7 @@ def json_stream_exists(request: HttpRequest, user_profile: UserProfile, stream_n
|
|||
def json_get_stream_id(request: HttpRequest,
|
||||
user_profile: UserProfile,
|
||||
stream_name: str=REQ('stream')) -> HttpResponse:
|
||||
(stream, recipient, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
(stream, sub) = access_stream_by_name(user_profile, stream_name)
|
||||
return json_success({'stream_id': stream.id})
|
||||
|
||||
@has_request_variables
|
||||
|
|
|
@ -248,14 +248,14 @@ def patch_bot_backend(
|
|||
if default_sending_stream == "":
|
||||
stream: Optional[Stream] = None
|
||||
else:
|
||||
(stream, recipient, sub) = access_stream_by_name(
|
||||
(stream, sub) = access_stream_by_name(
|
||||
user_profile, default_sending_stream)
|
||||
do_change_default_sending_stream(bot, stream, acting_user=user_profile)
|
||||
if default_events_register_stream is not None:
|
||||
if default_events_register_stream == "":
|
||||
stream = None
|
||||
else:
|
||||
(stream, recipient, sub) = access_stream_by_name(
|
||||
(stream, sub) = access_stream_by_name(
|
||||
user_profile, default_events_register_stream)
|
||||
do_change_default_events_register_stream(bot, stream, acting_user=user_profile)
|
||||
if default_all_public_streams is not None:
|
||||
|
@ -369,12 +369,12 @@ def add_bot_backend(
|
|||
|
||||
default_sending_stream = None
|
||||
if default_sending_stream_name is not None:
|
||||
(default_sending_stream, ignored_rec, ignored_sub) = access_stream_by_name(
|
||||
(default_sending_stream, ignored_sub) = access_stream_by_name(
|
||||
user_profile, default_sending_stream_name)
|
||||
|
||||
default_events_register_stream = None
|
||||
if default_events_register_stream_name is not None:
|
||||
(default_events_register_stream, ignored_rec, ignored_sub) = access_stream_by_name(
|
||||
(default_events_register_stream, ignored_sub) = access_stream_by_name(
|
||||
user_profile, default_events_register_stream_name)
|
||||
|
||||
if bot_type in (UserProfile.INCOMING_WEBHOOK_BOT, UserProfile.EMBEDDED_BOT) and service_name:
|
||||
|
|
Loading…
Reference in New Issue