streams: Add moderators option in stream_post_policy.

This commit adds a new option of STREAM_POST_POLICY_MODERATORS
in stream_post_policy which will allow only realm admins and
moderators to post in that stream.
This commit is contained in:
sahil839
2021-03-29 19:31:39 +05:30
committed by Tim Abbott
parent a061240251
commit 54be0dd1a4
5 changed files with 112 additions and 0 deletions

View File

@@ -195,6 +195,13 @@ def check_stream_access_based_on_stream_post_policy(sender: UserProfile, stream:
pass
elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_ADMINS:
raise JsonableError(_("Only organization administrators can send to this stream."))
elif (
stream.stream_post_policy == Stream.STREAM_POST_POLICY_MODERATORS
and not sender.is_moderator
):
raise JsonableError(
_("Only organization administrators and moderators can send to this stream.")
)
elif stream.stream_post_policy != Stream.STREAM_POST_POLICY_EVERYONE and sender.is_guest:
raise JsonableError(_("Guests cannot send to this stream."))
elif (