message_send: Fix old guests being treated as full members.

For streams in which only full members are allowed to post,
we block guest users from posting there.

Guests users were blocked from posting to admin only streams
already. So now, guest users can only post to
STREAM_POST_POLICY_EVERYONE streams.

This is not a new feature but a bugfix which should have
happened when implementing full member stream policy / guest users.
This commit is contained in:
Aman Agrawal
2020-10-09 00:00:11 +05:30
committed by GitHub
parent 6fe82620df
commit 8b419c93e4
4 changed files with 53 additions and 2 deletions

View File

@@ -184,6 +184,8 @@ def access_stream_for_send_message(sender: UserProfile,
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_EVERYONE and sender.is_guest:
raise JsonableError(_("Guests cannot send to this stream."))
elif stream.stream_post_policy == Stream.STREAM_POST_POLICY_RESTRICT_NEW_MEMBERS:
if sender.is_bot and (sender.bot_owner is not None and
sender.bot_owner.is_new_member):