message_edit: Clarify unmodified_user_messages logic.

This commit is contained in:
Tim Abbott 2023-04-20 17:28:56 -07:00 committed by Alex Vandiver
parent 13b9c87f93
commit fc679b09a3
1 changed files with 7 additions and 3 deletions

View File

@ -597,7 +597,7 @@ def do_update_message(
]
losing_access_user_ids = [sub.user_profile_id for sub in subs_losing_access]
ums = ums.exclude(
unmodified_user_messages = ums.exclude(
user_profile_id__in=[sub.user_profile_id for sub in subs_losing_usermessages]
)
@ -610,6 +610,10 @@ def do_update_message(
gaining_usermessage_user_ids += [
user_id for user_id in new_stream_user_ids if user_id not in old_stream_user_ids
]
else:
# If we're not moving the topic to another stream, we don't
# modify the original set of UserMessage objects queried.
unmodified_user_messages = ums
# We save the full topic name so that checks that require comparison
# between the original topic and the topic name passed into this function
@ -760,7 +764,7 @@ def do_update_message(
# in the organization (too expansive, and also not what we do for
# newly sent messages anyway) and having magical live-updates
# where possible.
users_to_be_notified = list(map(user_info, ums))
users_to_be_notified = list(map(user_info, unmodified_user_messages))
if stream_being_edited is not None and stream_being_edited.is_history_public_to_subscribers():
subscriptions = get_active_subscriptions_for_stream_id(
stream_id, include_deactivated_users=False
@ -773,7 +777,7 @@ def do_update_message(
# user both has a UserMessage row and is a current
# Subscriber
subscriptions = subscriptions.exclude(
user_profile_id__in=[um.user_profile_id for um in ums]
user_profile_id__in=[um.user_profile_id for um in unmodified_user_messages]
)
if new_stream is not None: