-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
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
settings: Add two realm settings to restrict direct messages. #28470
Conversation
Hello @zulip/server-settings members, this pull request was labeled with the "area: settings (admin/org)" label, so you may want to check it out! |
c3b7920
to
5c689cd
Compare
b905f28
to
7b237fb
Compare
4a459c7
to
e3d67f8
Compare
e3d67f8
to
7b76a31
Compare
zerver/models/messages.py
Outdated
return UserMessage.objects.select_related().get( | ||
user_profile=user_profile, message_id=message_id | ||
) | ||
return UserMessage.objects.get(user_profile=user_profile, message_id=message_id) |
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.
This first commit should have a commit message explaining why it's desirable and correct to remove this -- I know it's in the PR description, but it's the commits that are most handy for posterity.
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.
Added commit description.
zerver/migrations/0498_set_default_value_for_realm_direct_message_initiator_group_and_more.py
Outdated
Show resolved
Hide resolved
Also added Learn more link to |
321e8cd
to
f24f61c
Compare
Let's put the help |
We aren't ready to allow non-system groups to be used for permissions settings, so the UI options should be limited to system groups + nobody for now (confirmed with @timabbott ). |
Looking good other than that! I didn't test exhaustively, but did try a few variations of permission configurations. |
I noted that if you are composing a DM to a new conversation while viewing another conversation, and you aren't allowed to start conversations, you get a server banner when you try to send, but not a warning banner before you send. @timabbott tells me this is not easy to improve upon, though, so it's fine to leave as-is. Both types of banners for reference: |
Is there a distinct error code when I guess we don't necessarily need a distinct code as long as the error contains a user-facing string we can show the user. Does it? |
This has a reasonable user-facing error string, so there's no special My recommendation for mobile is just to have generic code for displaying generic 400 error sending failures to the user. |
settings_config.private_message_policy_values.by_anyone.code | ||
) { | ||
const {name} = user_groups.get_user_group_from_id(realm.realm_direct_message_permission_group); | ||
if (name !== "role:nobody") { |
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.
This check is OK for now but probably not the ideal way to check if nobody can authorize direct messages.
Can you do a follow-up commit that exports a function interface, user_groups.is_empty_group(realm.realm_direct_message_permission_group)
, replacing all the role:nobody
checks in the web frontend?
That implementation should probably work by just walking the actual membership to see if it's empty.
447bf55
to
5e558e1
Compare
Removes `private_message_policy` field from both the API and the backend.
Done. |
I think this is probably an issue that we need to audit all the group-based settings that we've merged recently for. I don't really remember what the right way to control this is; @sahil839 can you perhaps put up a follow-up PR for adjusting that? I think otherwise this is good to merge, so I'm going to do that to keep the migration numbering going. @Vector73 please follow-up on #28470 (comment). @alya FYI. |
We show user defined groups as options in a couple of newly added settings as we have the UI to allow a single user group to be used for a setting. I don't see any problem in allowing them to provide users the flexibility to create a user group with the intended members for now till we add the UI to allow a combination of users and groups. |
Opened a follow-up PR #30810. |
1st commit adds
is_any_user_in_group
function inlib/user_groups.py
.2nd commit adds two realm settings:
direct_message_initiator_group
- ID of the user group whose members can initiate direct message thread.direct_message_permission_group
- ID of the user group of which at least member must be included as sender or recipient in personal and group direct messages.3rd commit removes
private_message_policy
setting.Fixes: #24467
Screenshots and screen captures:
Screenshots
Self-review checklist
(variable names, code reuse, readability, etc.).
Communicate decisions, questions, and potential concerns.
Individual commits are ready for review (see commit discipline).
Completed manual review and testing of the following: