delete_messages: Pass a list of user ids in the event in all cases.

The bulk deletion codepath was using dicts instead of user ids in the
event, as opposed to the other codepath which was adjusted to pass just
user ids before. We make the bulk codepath consistent with the other
one. Due to the dict-type events happening in 3.*, we move the goal for
deleting the compat code in process_notification to 5.0.
This commit is contained in:
Mateusz Mandera 2021-04-15 19:06:05 +02:00 committed by Tim Abbott
parent 8ffb828030
commit c3a8a15bae
2 changed files with 3 additions and 3 deletions

View File

@ -5790,8 +5790,7 @@ def do_delete_messages(realm: Realm, messages: Iterable[Message]) -> None:
subscribers = get_active_subscriptions_for_stream_id(stream_id)
# We exclude long-term idle users, since they by definition have no active clients.
subscribers = subscribers.exclude(user_profile__long_term_idle=True)
subscriber_ids = [user.user_profile_id for user in subscribers]
users_to_notify = list(map(subscriber_info, subscriber_ids))
users_to_notify = list(subscribers.values_list("user_profile_id", flat=True))
archiving_chunk_size = retention.STREAM_MESSAGE_BATCH_SIZE
move_messages_to_archive(message_ids, realm=realm, chunk_size=archiving_chunk_size)

View File

@ -1206,7 +1206,8 @@ def process_notification(notice: Mapping[str, Any]) -> None:
# compatibility with events in that format still in the
# queue at the time of upgrade.
#
# TODO: Remove this block in release >= 4.0.
# TODO/compatibility: Remove this block once you can no
# longer directly upgrade directly from 3.x to master.
user_ids: List[int] = [user["id"] for user in cast(List[Mapping[str, int]], users)]
else:
user_ids = cast(List[int], users)