message: Check stream_post_policy when moving messages between streams.

Previously only admins were allowed to move messages between streams
and admins are allowed to post in any stream irresepctive of stream
post policy, so there was no need to check for stream post policy.

But as we now allow other members to also move messages, we need
to check whether the user who is moving the message is allowed
to post to the target stream (i.e. stream to which the messages
are being moved) and thus we allow moving messages only if the
user is allowed to post in target stream.
This commit is contained in:
sahil839
2021-05-05 01:28:01 +05:30
committed by Tim Abbott
parent f1cf9f740d
commit 213eda1f32
2 changed files with 89 additions and 1 deletions

View File

@@ -143,6 +143,7 @@ from zerver.lib.streams import (
access_stream_by_id,
access_stream_for_send_message,
can_access_stream_user_ids,
check_stream_access_based_on_stream_post_policy,
check_stream_name,
create_stream_if_needed,
get_default_value_for_history_public_to_subscribers,
@@ -2816,6 +2817,7 @@ def check_update_message(
raise JsonableError(_("Cannot change message content while changing stream"))
new_stream = access_stream_by_id(user_profile, stream_id, require_active=True)[0]
check_stream_access_based_on_stream_post_policy(user_profile, new_stream)
number_changed = do_update_message(
user_profile,