Skip to content

Commit d233d08

Browse files
committed
boxes: Add warning when sending message to announcement streams
Normal users are not allowed to send messages in announcement streams, currently when an unauthorised user sends message to this stream, nothing happens. This commit changes this behaviour and adds a footer warning for the same. Fixes: #682
1 parent 49d3fa5 commit d233d08

File tree

1 file changed

+17
-4
lines changed

1 file changed

+17
-4
lines changed

zulipterminal/ui_tools/boxes.py

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,23 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
751751
email=self.recipients_emails
752752
)
753753
elif self.message['type'] == 'stream':
754-
self.model.controller.view.write_box.stream_box_view(
755-
caption=self.message['display_recipient'],
756-
title=self.message['subject']
757-
)
754+
# Check if user is allowed to post
755+
if (self.model.stream_dict[self.message.get('stream_id')].
756+
get('is_announcement_only', None) == 1
757+
or (self.model.initial_data.get('is_admin', None)
758+
or self.model.initial_data.get('is_owner', None)
759+
and self.model.stream_dict[self.message.get('stream_id')].
760+
get('stream_post_policy', None) == 2)):
761+
self.msg_footer = (
762+
self.model.controller.view.set_footer_text(
763+
"You are not authorised to send messages "
764+
"to this stream.",
765+
5))
766+
else:
767+
self.model.controller.view.write_box.stream_box_view(
768+
caption=self.message['display_recipient'],
769+
title=self.message['subject']
770+
)
758771
elif is_command_key('STREAM_MESSAGE', key):
759772
if self.message['type'] == 'private':
760773
self.model.controller.view.write_box.private_box_view(

0 commit comments

Comments
 (0)