Skip to content
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

DEV: Remove policy_max_group_size site setting #43

Merged
merged 1 commit into from
Dec 9, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions app/controllers/policy_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ def set_post
return render_json_error(I18n.t("discourse_policy.errors.user_missing"))
end

if group.user_count > SiteSetting.policy_max_group_size
return render_json_error(I18n.t("discourse_policy.errors.too_large"))
end

if SiteSetting.policy_restrict_to_staff_posts && [email protected]&.staff?
return render_json_error(I18n.t("discourse_policy.errors.staff_only"))
end
Expand Down
1 change: 0 additions & 1 deletion app/models/post_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ def policy_group
return @policy_group if defined?(@policy_group)

@policy_group = Group
.where('user_count < ?', SiteSetting.policy_max_group_size)
.where('id in (SELECT group_id FROM post_policies WHERE post_id = ?)', post.id)
.first
end
Expand Down
2 changes: 0 additions & 2 deletions config/locales/server.en.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
en:
site_settings:
policy_enabled: "Allow policies?"
policy_max_group_size: "Maximum number of users in a group that can have a policy applied"
policy_restrict_to_staff_posts: "Policies may only appear on staff posts"
policy_easy_revoke: "Show the accept and revoke buttons at the same time"
discourse_policy:
errors:
too_large: "Group is too large, it can not accept policies"
user_missing: "User does not exist in group"
group_not_found: "Group not found for policy"
no_policy: "No policy exists for post"
Expand Down
1 change: 0 additions & 1 deletion config/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ plugins:
policy_enabled:
default: true
client: true
policy_max_group_size: 200
policy_restrict_to_staff_posts:
client: true
default: true
Expand Down
17 changes: 0 additions & 17 deletions spec/requests/policy_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,6 @@
group.add(user2)
end

it 'can not apply a policy to groups that are too big' do
SiteSetting.policy_max_group_size = 1

raw = <<~MD
[policy group=#{group.name}]
I always open **doors**!
[/policy]
MD

post = create_post(raw: raw, user: moderator)

sign_in(user1)
put "/policy/accept.json", params: { post_id: post.id }
expect(response.status).not_to eq(200)
expect(response.body).to include('too large')
end

it 'can allows users to accept/reject policy' do
raw = <<~MD
[policy group=#{group.name}]
Expand Down