mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06: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
@@ -164,6 +164,8 @@ describe "Admin Flags Page", type: :system do
|
||||
admin_flags_page.click_tab("settings")
|
||||
expect(page.all(".setting-label h3").map(&:text).map(&:downcase)).to eq(
|
||||
[
|
||||
"allow tl0 and anonymous users to flag illegal content",
|
||||
"email address to report illegal content",
|
||||
"silence new user sensitivity",
|
||||
"num users to silence new user",
|
||||
"flag sockpuppets",
|
||||
|
||||
@@ -2,21 +2,23 @@
|
||||
|
||||
describe "Flagging post", type: :system do
|
||||
fab!(:current_user) { Fabricate(:admin) }
|
||||
fab!(:first_post) { Fabricate(:post) }
|
||||
fab!(:post_to_flag) { Fabricate(:post, topic: first_post.topic) }
|
||||
fab!(:category)
|
||||
fab!(:topic) { Fabricate(:topic, category: category) }
|
||||
fab!(:first_post) { Fabricate(:post, topic: topic) }
|
||||
fab!(:post_to_flag) { Fabricate(:post, topic: topic) }
|
||||
|
||||
let(:topic_page) { PageObjects::Pages::Topic.new }
|
||||
let(:flag_modal) { PageObjects::Modals::Flag.new }
|
||||
|
||||
before { sign_in(current_user) }
|
||||
|
||||
describe "Using Take Action" do
|
||||
before { sign_in(current_user) }
|
||||
|
||||
it "can select the default action to hide the post, agree with other flags, and reach the flag threshold" do
|
||||
other_flag = Fabricate(:flag_post_action, post: post_to_flag, user: Fabricate(:moderator))
|
||||
other_flag_reviewable =
|
||||
Fabricate(:reviewable_flagged_post, target: post_to_flag, created_by: other_flag.user)
|
||||
expect(other_flag.reload.agreed_at).to be_nil
|
||||
topic_page.visit_topic(post_to_flag.topic)
|
||||
topic_page.visit_topic(topic)
|
||||
topic_page.expand_post_actions(post_to_flag)
|
||||
topic_page.click_post_action_button(post_to_flag, :flag)
|
||||
flag_modal.choose_type(:off_topic)
|
||||
@@ -34,8 +36,10 @@ describe "Flagging post", type: :system do
|
||||
end
|
||||
|
||||
describe "As Illegal" do
|
||||
before { sign_in(current_user) }
|
||||
|
||||
it do
|
||||
topic_page.visit_topic(post_to_flag.topic)
|
||||
topic_page.visit_topic(topic)
|
||||
topic_page.expand_post_actions(post_to_flag)
|
||||
topic_page.click_post_action_button(post_to_flag, :flag)
|
||||
flag_modal.choose_type(:illegal)
|
||||
@@ -50,4 +54,63 @@ describe "Flagging post", type: :system do
|
||||
expect(page).to have_content(I18n.t("js.post.actions.by_you.illegal"))
|
||||
end
|
||||
end
|
||||
|
||||
context "when tl0" do
|
||||
fab!(:tl0_user) { Fabricate(:user, trust_level: TrustLevel[0]) }
|
||||
before { sign_in(tl0_user) }
|
||||
|
||||
it "does not allow to mark posts as illegal" do
|
||||
topic_page.visit_topic(topic)
|
||||
topic_page.expand_post_actions(post_to_flag)
|
||||
expect(topic_page).to have_no_flag_button
|
||||
end
|
||||
|
||||
it "allows to mark posts as illegal when allow_tl0_and_anonymous_users_to_flag_illegal_content setting is enabled" do
|
||||
SiteSetting.email_address_to_report_illegal_content = "illegal@example.com"
|
||||
SiteSetting.allow_tl0_and_anonymous_users_to_flag_illegal_content = true
|
||||
topic_page.visit_topic(topic).open_flag_topic_modal
|
||||
expect(flag_modal).to have_choices(I18n.t("js.flagging.formatted_name.illegal"))
|
||||
end
|
||||
end
|
||||
|
||||
context "when anonymous" do
|
||||
let(:anonymous_flag_modal) { PageObjects::Modals::AnonymousFlag.new }
|
||||
|
||||
it "does not allow to mark posts as illegal" do
|
||||
topic_page.visit_topic(topic)
|
||||
expect(topic_page).to have_no_post_more_actions(post_to_flag)
|
||||
end
|
||||
|
||||
it "allows to mark posts as illegal when allow_tl0_and_anonymous_users_to_flag_illegal_content setting is enabled" do
|
||||
SiteSetting.contact_email = "contact@example.com"
|
||||
SiteSetting.allow_tl0_and_anonymous_users_to_flag_illegal_content = true
|
||||
|
||||
topic_page.visit_topic(topic, post_number: post_to_flag.post_number)
|
||||
topic_page.expand_post_actions(post_to_flag)
|
||||
topic_page.find_post_action_button(post_to_flag, :flag).click
|
||||
|
||||
expect(anonymous_flag_modal.body).to have_content(
|
||||
ActionView::Base.full_sanitizer.sanitize(
|
||||
I18n.t(
|
||||
"js.anonymous_flagging.description",
|
||||
{ email: "contact@example.com", topic_title: topic.title, url: current_url },
|
||||
),
|
||||
),
|
||||
)
|
||||
|
||||
SiteSetting.email_address_to_report_illegal_content = "illegal@example.com"
|
||||
topic_page.visit_topic(topic)
|
||||
topic_page.expand_post_actions(post_to_flag)
|
||||
topic_page.find_post_action_button(post_to_flag, :flag).click
|
||||
|
||||
expect(anonymous_flag_modal.body).to have_content(
|
||||
ActionView::Base.full_sanitizer.sanitize(
|
||||
I18n.t(
|
||||
"js.anonymous_flagging.description",
|
||||
{ email: "illegal@example.com", topic_title: topic.title, url: current_url },
|
||||
),
|
||||
),
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
9
spec/system/page_objects/modals/anonoymous_flag.rb
Normal file
9
spec/system/page_objects/modals/anonoymous_flag.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
module PageObjects
|
||||
module Modals
|
||||
class AnonymousFlag < PageObjects::Modals::Base
|
||||
BODY_SELECTOR = ".anonymous-flag-modal__body"
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -78,6 +78,10 @@ module PageObjects
|
||||
".topic-post:not(.staged) #post_#{post_number}"
|
||||
end
|
||||
|
||||
def has_no_post_more_actions?(post)
|
||||
within_post(post) { has_no_css?(".show-more-actions") }
|
||||
end
|
||||
|
||||
def has_post_more_actions?(post)
|
||||
within_post(post) { has_css?(".show-more-actions") }
|
||||
end
|
||||
@@ -300,6 +304,10 @@ module PageObjects
|
||||
find(".modal.convert-to-public-topic")
|
||||
end
|
||||
|
||||
def has_no_flag_button?
|
||||
has_no_css?(".post-action-menu__flag.create-flag")
|
||||
end
|
||||
|
||||
def open_flag_topic_modal
|
||||
expect(page).to have_css(".flag-topic", wait: Capybara.default_max_wait_time * 3)
|
||||
find(".flag-topic").click
|
||||
|
||||
Reference in New Issue
Block a user