-
-
Notifications
You must be signed in to change notification settings - Fork 286
[WIP] Add warning when sending message to announcement streams #693
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Hi, maintainers. |
|
@imnitishng thanks for the PR! |
|
@imnitishng You seem to have the right broad idea here, but as @kaustubh-nair mentions, there is a pre-existing method we likely want to use here to set the text in the footer (for a short time). The check likely wants to be triggered upon any composing keypress. |
237cb26 to
935b5dd
Compare
|
Hi @kaustubh-nair @neiljp, thanks a lot for the help. |
neiljp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imnitishng This looks to use the existing code more, but after a little manual testing it seems to get stuck. I've given a pointer as to why this is the case and how you might move the code around to fix it.
Note that you can place the 'fixes' line at the end of the commit too, and it will close the issue when the commit is merged :)
We don't seem to have the stream property you're using here in any test or fixtures yet, so if you wanted to work on that at the same time or afterwards you'd be welcome to do that. I've not checked which version of the server added the stream property we're using here, but we may need to think about that and check; we're currently focusing on targeting version 2.1 as the minimum server version.
935b5dd to
47a1f88
Compare
Sure I would love to add some tests for this PR and other missed methods.
I went through the changelogs of Zulip API and found that the attribute |
|
Ah, good job noticing that - I think using |
47a1f88 to
e022c05
Compare
e022c05 to
d233d08
Compare
I have updated the PR keeping this in mind. Please have a look. |
|
I think this will be simpler once #653 is merged, so we can check directly based on server versions |
neiljp
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imnitishng This seems to work fine in my manual testing, in terms of limiting myself posting as a non-admin 👍
I'm happy to merge a simple version similar to this, but if we look for the next version features then we should consider how to structure and test it further. Let us know how you far you'd like to take this 👍
zulipterminal/ui_tools/boxes.py
Outdated
| if (self.model.stream_dict[self.message.get('stream_id')]. | ||
| get('is_announcement_only', None) == 1 | ||
| or (self.model.initial_data.get('is_admin', None) | ||
| or self.model.initial_data.get('is_owner', None) | ||
| and self.model.stream_dict[self.message.get('stream_id')]. | ||
| get('stream_post_policy', None) == 2)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is_announcement_only is still present in what will soon be 3.0, so we could stick with just it for now to begin with, since it works across the versions we plan to support.
If we support the new versions, we should likely have this logic in the model, in any case.
We'd ideally want tests against the two different server versions (or feature levels). While we added some background for this in #653, we don't have good examples of using this in a feature like this yet, so you're welcome to give it a go but you may wish to discuss on the stream about this first.
preetmishra
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@imnitishng Thanks for working on this. I ran your changes locally. It seems to work well for the case when a message is directly being sent from the 'announce' stream. 👍
However, when the compose box is already open, in some other stream, and I am trying to send a message to the 'announce' stream, there is no feedback. We may want to have a footer update for this case as well.
|
@imnitishng Just checking with you if you plan to take this further in the near term, as this is something we'd like to integrate soon. |
|
Hi @neiljp, I am occupied as of now so someone else can take this up. |
|
@imnitishng I've added WIP here to indicate the status, though you're welcome to take this up again at some point of course :) |
d233d08 to
84caa04
Compare
84caa04 to
cdc1b7b
Compare
This method acts as an sanitary check when a normal user is sending message to a stream where only organization admins are allowed to send. The method also updates the footer with appropriate warning.
This commit adds warning for when an unauthorised user tries to send a message to an admin only stream.
cdc1b7b to
9eebbee
Compare
|
Heads up @imnitishng, we just merged some commits that conflict with the changes your made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |

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