Skip to content

Commit 9eebbee

Browse files
committed
boxes.py: Add warning when user without permission sends message
This commit adds warning for when an unauthorised user tries to send a message to an admin only stream.
1 parent a7b99be commit 9eebbee

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

zulipterminal/ui_tools/boxes.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
)
2525
from zulipterminal.helper import (
2626
Message, format_string, match_emoji, match_group, match_stream,
27-
match_topics, match_user,
27+
match_topics, match_user, unauthorised_warning,
2828
)
2929
from zulipterminal.ui_tools.buttons import EditModeButton
3030
from zulipterminal.ui_tools.tables import render_table
@@ -440,6 +440,8 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
440440
)
441441
self.view.set_footer_text(invalid_stream_error, 3)
442442
return key
443+
elif unauthorised_warning(self.model, stream_name):
444+
return key
443445
user_ids = self.model.get_other_subscribers_in_stream(
444446
stream_name=stream_name)
445447
self.recipient_user_ids = user_ids
@@ -1166,11 +1168,13 @@ def keypress(self, size: urwid_Size, key: str) -> Optional[str]:
11661168
recipient_user_ids=self.recipient_ids,
11671169
)
11681170
elif self.message['type'] == 'stream':
1169-
self.model.controller.view.write_box.stream_box_view(
1170-
caption=self.message['display_recipient'],
1171-
title=self.message['subject'],
1172-
stream_id=self.stream_id,
1173-
)
1171+
if not unauthorised_warning(self.model,
1172+
self.message.get('stream_id')):
1173+
self.model.controller.view.write_box.stream_box_view(
1174+
caption=self.message['display_recipient'],
1175+
title=self.message['subject'],
1176+
stream_id=self.stream_id,
1177+
)
11741178
elif is_command_key('STREAM_MESSAGE', key):
11751179
if self.message['type'] == 'private':
11761180
self.model.controller.view.write_box.private_box_view(

0 commit comments

Comments
 (0)