mirror of
https://github.com/zulip/zulip.git
synced 2025-11-10 17:07:07 +00:00
message: Add a bulk_access_stream_messages_query method.
This applies access restrictions in SQL, so that individual messages
do not need to be walked one-by-one. It only functions for stream
messages.
Use of this method significantly speeds up checks if we moved "all
visible messages" in a topic, since we no longer need to walk every
remaining message in the old topic to determine that at least one was
visible to the user. Similarly, it significantly speeds up merging
into existing topics, since it no longer must walk every message in
the new topic to determine if the user could see at least one.
Finally, it unlocks the ability to bulk-update only messages the user
has access to, in a single query (see subsequent commit).
(cherry picked from commit 7dcc7540f9)
This commit is contained in:
committed by
Tim Abbott
parent
9ac6ca1545
commit
9a2a5b5910
@@ -173,9 +173,9 @@ def update_messages_for_topic_edit(
|
||||
# If we're moving the messages between streams, only move
|
||||
# messages that the acting user can access, so that one cannot
|
||||
# gain access to messages through moving them.
|
||||
from zerver.lib.message import bulk_access_messages
|
||||
from zerver.lib.message import bulk_access_stream_messages_query
|
||||
|
||||
messages_list = bulk_access_messages(acting_user, messages, stream=old_stream)
|
||||
messages_list = list(bulk_access_stream_messages_query(acting_user, messages, old_stream))
|
||||
else:
|
||||
# For single-message edits or topic moves within a stream, we
|
||||
# allow moving history the user may not have access in order
|
||||
|
||||
Reference in New Issue
Block a user