mirror of
https://github.com/zulip/zulip.git
synced 2026-07-06 21:18:58 +08:00
typing: Add none-checks for Recipient objects.
Signed-off-by: Zixuan James Li <359101898@qq.com>
This commit is contained in:
parent
bb6a934c8d
commit
e338ada66c
@ -420,6 +420,7 @@ def archive_stream_messages(
|
||||
recipients = [stream.recipient for stream in streams]
|
||||
message_count = 0
|
||||
for recipient in recipients:
|
||||
assert recipient is not None
|
||||
message_count += archive_messages_by_recipient(
|
||||
recipient,
|
||||
retention_policy_dict[recipient.type_id],
|
||||
|
||||
@ -450,6 +450,7 @@ class MessageHydrationTest(ZulipTestCase):
|
||||
|
||||
cordelia_recipient = cordelia.recipient
|
||||
# Cause the display_recipient to get cached:
|
||||
assert cordelia_recipient is not None
|
||||
get_display_recipient(cordelia_recipient)
|
||||
|
||||
# Change cordelia's email:
|
||||
|
||||
@ -1378,6 +1378,9 @@ class GetOldMessagesTest(ZulipTestCase):
|
||||
query_ids: Dict[str, Union[int, str]] = {}
|
||||
|
||||
scotland_stream = get_stream("Scotland", hamlet_user.realm)
|
||||
assert scotland_stream.recipient_id is not None
|
||||
assert hamlet_user.recipient_id is not None
|
||||
assert othello_user.recipient_id is not None
|
||||
query_ids["scotland_recipient"] = scotland_stream.recipient_id
|
||||
query_ids["hamlet_id"] = hamlet_user.id
|
||||
query_ids["othello_id"] = othello_user.id
|
||||
|
||||
@ -118,6 +118,7 @@ class MutedTopicsTests(ZulipTestCase):
|
||||
# trying to mute the topic. To do this, we patch the
|
||||
# topic_is_muted function to always return False when trying
|
||||
# to mute a topic that is already muted.
|
||||
assert stream.recipient is not None
|
||||
add_topic_mute(
|
||||
user_profile=user,
|
||||
stream_id=stream.id,
|
||||
|
||||
@ -298,6 +298,7 @@ class NarrowBuilder:
|
||||
return query.where(maybe_negate(cond))
|
||||
|
||||
recipient = stream.recipient
|
||||
assert recipient is not None
|
||||
cond = column("recipient_id", Integer) == recipient.id
|
||||
return query.where(maybe_negate(cond))
|
||||
|
||||
|
||||
@ -82,6 +82,7 @@ def mark_topic_as_read(
|
||||
topic_name: str = REQ(),
|
||||
) -> HttpResponse:
|
||||
stream, sub = access_stream_by_id(user_profile, stream_id)
|
||||
assert stream.recipient_id is not None
|
||||
|
||||
if topic_name:
|
||||
topic_exists = user_message_exists_for_topic(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user