mirror of
https://github.com/discourse/discourse.git
synced 2025-05-30 15:28:37 +08:00
FEATURE: setting allowing tl0/anonymous flag illegal content (#30785)
The new site setting `allow_anonymous_and_tl0_to_flag_illegal` allows tl0 users to flag illegal content. In addition, anonymous users are instructed on how to flag illegal content by sending emails. Also `email_address_to_report_illegal_content` setting is added. If not provided, then the site contact email is used.
This commit is contained in:

committed by
GitHub

parent
d3a7b99699
commit
029bd6feda
@ -163,6 +163,16 @@ RSpec.describe Guardian do
|
||||
Flag.reset_flag_settings!
|
||||
end
|
||||
|
||||
it "return true for illegal if tl0 and allow_tl0_and_anonymous_users_to_flag_illegal_content" do
|
||||
SiteSetting.flag_post_allowed_groups = ""
|
||||
user.trust_level = TrustLevel[0]
|
||||
expect(Guardian.new(user).post_can_act?(post, :illegal)).to be false
|
||||
|
||||
SiteSetting.email_address_to_report_illegal_content = "illegal@example.com"
|
||||
SiteSetting.allow_tl0_and_anonymous_users_to_flag_illegal_content = true
|
||||
expect(Guardian.new(user).post_can_act?(post, :illegal)).to be true
|
||||
end
|
||||
|
||||
it "works as expected for silenced users" do
|
||||
UserSilencer.silence(user, admin)
|
||||
|
||||
|
@ -474,4 +474,19 @@ RSpec.describe SiteSettings::Validations do
|
||||
expect { validations.validate_twitter_summary_large_image(nil) }.not_to raise_error
|
||||
end
|
||||
end
|
||||
|
||||
describe "#validate_allow_tl0_and_anonymous_users_to_flag_illegal_content" do
|
||||
it "does not allow to enable when no contact email is provided" do
|
||||
expect {
|
||||
validations.validate_allow_tl0_and_anonymous_users_to_flag_illegal_content("t")
|
||||
}.to raise_error(
|
||||
Discourse::InvalidParameters,
|
||||
I18n.t("errors.site_settings.tl0_and_anonymous_flag"),
|
||||
)
|
||||
SiteSetting.contact_email = "illegal@example.com"
|
||||
expect {
|
||||
validations.validate_allow_tl0_and_anonymous_users_to_flag_illegal_content("t")
|
||||
}.not_to raise_error
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Reference in New Issue
Block a user