Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

message_edit: Clarify losing_access_user_ids calculation.

Tim Abbotta03dca93cafb
diff --git a/zerver/actions/message_edit.py b/zerver/actions/message_edit.py
index 41aac51d2e7..8054ab94592 100644
--- a/zerver/actions/message_edit.py
+++ b/zerver/actions/message_edit.py
@@ -494,6 +494,7 @@ def do_update_message(
orig_topic_name = target_message.topic_name()
event["propagate_mode"] = propagate_mode
+ losing_access_user_ids: List[int] = []
if new_stream is not None:
assert content is None
assert target_message.is_stream_message()
@@ -538,6 +539,8 @@ def do_update_message(
for sub in subs_losing_usermessages
if sub.user_profile.is_guest or not new_stream.is_public()
]
+ losing_access_user_ids = [sub.user_profile_id for sub in subs_losing_access]
+
ums = ums.exclude(
user_profile_id__in=[sub.user_profile_id for sub in subs_losing_usermessages]
)
@@ -586,7 +589,6 @@ def do_update_message(
target_stream.recipient_id, target_topic
).exists()
- delete_event_notify_user_ids: List[int] = []
if propagate_mode in ["change_later", "change_all"]:
assert topic_name is not None or new_stream is not None
assert stream_being_edited is not None
@@ -654,8 +656,7 @@ def do_update_message(
"stream_id": stream_being_edited.id,
"topic": orig_topic_name,
}
- delete_event_notify_user_ids = [sub.user_profile_id for sub in subs_losing_access]
- send_event(user_profile.realm, delete_event, delete_event_notify_user_ids)
+ send_event(user_profile.realm, delete_event, losing_access_user_ids)
# Reset the Attachment.is_*_public caches for all messages
# moved to another stream with different access permissions.
@@ -720,8 +721,7 @@ def do_update_message(
)
if new_stream is not None:
- assert delete_event_notify_user_ids is not None
- subscriptions = subscriptions.exclude(user_profile_id__in=delete_event_notify_user_ids)
+ subscriptions = subscriptions.exclude(user_profile_id__in=losing_access_user_ids)
# All users that are subscribed to the stream must be
# notified when a message is edited
@@ -807,10 +807,7 @@ def do_update_message(
for user_topic in get_users_with_user_topic_visibility_policy(
stream_being_edited.id, orig_topic_name
):
- if (
- new_stream is not None
- and user_topic.user_profile_id in delete_event_notify_user_ids
- ):
+ if new_stream is not None and user_topic.user_profile_id in losing_access_user_ids:
stream_inaccessible_to_user_profiles.append(user_topic.user_profile)
else:
orig_topic_user_profile_to_visibility_policy[