message_edit: Do not reuse user_profile variable in "for" loop.

Doing so causes the "username resolved this topic" or "this topic was
moved by username" notifications to be attributed to a random user who
had a visibility policy on the topic.
This commit is contained in:
Alex Vandiver 2023-05-09 15:47:42 +00:00 committed by Tim Abbott
parent cce0c57a04
commit 89d4737ab2
1 changed files with 7 additions and 7 deletions

View File

@ -832,25 +832,25 @@ def do_update_message(
user_profiles_for_visibility_policy_pair: Dict[ user_profiles_for_visibility_policy_pair: Dict[
Tuple[int, int], List[UserProfile] Tuple[int, int], List[UserProfile]
] = defaultdict(list) ] = defaultdict(list)
for user_profile in user_profiles_having_visibility_policy: for user_profile_with_policy in user_profiles_having_visibility_policy:
if user_profile not in target_topic_user_profile_to_visibility_policy: if user_profile_with_policy not in target_topic_user_profile_to_visibility_policy:
target_topic_user_profile_to_visibility_policy[ target_topic_user_profile_to_visibility_policy[
user_profile user_profile_with_policy
] = UserTopic.VisibilityPolicy.INHERIT ] = UserTopic.VisibilityPolicy.INHERIT
elif user_profile not in orig_topic_user_profile_to_visibility_policy: elif user_profile not in orig_topic_user_profile_to_visibility_policy:
orig_topic_user_profile_to_visibility_policy[ orig_topic_user_profile_to_visibility_policy[
user_profile user_profile_with_policy
] = UserTopic.VisibilityPolicy.INHERIT ] = UserTopic.VisibilityPolicy.INHERIT
orig_topic_visibility_policy = orig_topic_user_profile_to_visibility_policy[ orig_topic_visibility_policy = orig_topic_user_profile_to_visibility_policy[
user_profile user_profile_with_policy
] ]
target_topic_visibility_policy = target_topic_user_profile_to_visibility_policy[ target_topic_visibility_policy = target_topic_user_profile_to_visibility_policy[
user_profile user_profile_with_policy
] ]
user_profiles_for_visibility_policy_pair[ user_profiles_for_visibility_policy_pair[
(orig_topic_visibility_policy, target_topic_visibility_policy) (orig_topic_visibility_policy, target_topic_visibility_policy)
].append(user_profile) ].append(user_profile_with_policy)
# If the messages are being moved to a stream the user # If the messages are being moved to a stream the user
# cannot access, then we treat this as the # cannot access, then we treat this as the