FIX: discobot inappropriate flag section
Ensure that the inappropriate flag is used and not some other flag type. If some other flag is used a message will be posted letting the user know they used the wrong flag and the original flag will be removed so that they can try again. Bug reported on meta: https://meta.discourse.org/t/-/157075
This commit is contained in:
parent
8246b611ac
commit
18dad4cfbd
|
@ -291,7 +291,7 @@ en:
|
||||||
reply: |-
|
reply: |-
|
||||||
[Our staff](%{base_uri}/groups/staff) will be privately notified about your flag. If enough community members flag a post, it will also be automatically hidden as a precaution. (Since I didn’t actually write a nasty post :angel:, I’ve gone ahead and removed the flag for now.)
|
[Our staff](%{base_uri}/groups/staff) will be privately notified about your flag. If enough community members flag a post, it will also be automatically hidden as a precaution. (Since I didn’t actually write a nasty post :angel:, I’ve gone ahead and removed the flag for now.)
|
||||||
not_found: |-
|
not_found: |-
|
||||||
Oh no, my nasty post hasn’t been flagged yet. :worried: Can you flag it as inappropriate using the **flag** <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-flag.png" width="16" height="16">? Don’t forget to use the show more button <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> to reveal more actions for each post.
|
Oh no, my nasty post hasn’t been flagged as inappropriate yet. :worried: Can you flag it as inappropriate using the **flag** <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-flag.png" width="16" height="16">? Don’t forget to use the show more button <img src="%{base_uri}/plugins/discourse-narrative-bot/images/font-awesome-ellipsis.png" width="16" height="16"> to reveal more actions for each post.
|
||||||
|
|
||||||
search:
|
search:
|
||||||
instructions: |-
|
instructions: |-
|
||||||
|
|
|
@ -474,7 +474,14 @@ module DiscourseNarrativeBot
|
||||||
|
|
||||||
def missing_flag
|
def missing_flag
|
||||||
return unless valid_topic?(@post.topic_id)
|
return unless valid_topic?(@post.topic_id)
|
||||||
return if @post.user_id == -2
|
|
||||||
|
# Remove any incorrect flags so that they can try again
|
||||||
|
if @post.user_id == -2
|
||||||
|
@post.post_actions
|
||||||
|
.where(user_id: @user.id)
|
||||||
|
.where("post_action_type_id IN (?)", (PostActionType.flag_types.values - [PostActionType.types[:inappropriate]]))
|
||||||
|
.destroy_all
|
||||||
|
end
|
||||||
|
|
||||||
fake_delay
|
fake_delay
|
||||||
reply_to(@post, I18n.t("#{I18N_KEY}.flag.not_found", i18n_post_args)) unless @data[:attempted]
|
reply_to(@post, I18n.t("#{I18N_KEY}.flag.not_found", i18n_post_args)) unless @data[:attempted]
|
||||||
|
|
|
@ -223,8 +223,8 @@ after_initialize do
|
||||||
if self.post && self.user.enqueue_narrative_bot_job?
|
if self.post && self.user.enqueue_narrative_bot_job?
|
||||||
input =
|
input =
|
||||||
case self.post_action_type_id
|
case self.post_action_type_id
|
||||||
when *PostActionType.flag_types_without_custom.values
|
when *PostActionType.flag_types.values
|
||||||
:flag
|
self.post_action_type_id == PostActionType.types[:inappropriate] ? :flag : :reply
|
||||||
when PostActionType.types[:like]
|
when PostActionType.types[:like]
|
||||||
:like
|
:like
|
||||||
when PostActionType.types[:bookmark]
|
when PostActionType.types[:bookmark]
|
||||||
|
|
|
@ -840,7 +840,9 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
||||||
|
|
||||||
describe 'flag tutorial' do
|
describe 'flag tutorial' do
|
||||||
let(:post) { Fabricate(:post, user: discobot_user, topic: topic) }
|
let(:post) { Fabricate(:post, user: discobot_user, topic: topic) }
|
||||||
let(:flag) { Fabricate(:flag, post: post, user: user) }
|
let(:another_post) { Fabricate(:post, user: discobot_user, topic: topic) }
|
||||||
|
let(:flag) { Fabricate(:flag, post: post, user: user, post_action_type_id: PostActionType.types[:inappropriate]) }
|
||||||
|
let(:other_flag) { Fabricate(:flag, post: another_post, user: user, post_action_type_id: PostActionType.types[:spam]) }
|
||||||
let(:other_post) { Fabricate(:post, user: user, topic: topic) }
|
let(:other_post) { Fabricate(:post, user: user, topic: topic) }
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -858,6 +860,17 @@ describe DiscourseNarrativeBot::NewUserNarrative do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe 'when post is flagged incorrectly' do
|
||||||
|
it 'should create the right reply and stay on the same step' do
|
||||||
|
narrative.expects(:enqueue_timeout_job).with(user).never
|
||||||
|
other_flag.update!(post: another_post)
|
||||||
|
new_post = Post.last
|
||||||
|
|
||||||
|
expect(new_post.raw).to eq(I18n.t('discourse_narrative_bot.new_user_narrative.flag.not_found', base_uri: ''))
|
||||||
|
expect(narrative.get_data(user)[:state].to_sym).to eq(:tutorial_flag)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe 'when post being flagged does not belong to discobot ' do
|
describe 'when post being flagged does not belong to discobot ' do
|
||||||
it 'should not do anything' do
|
it 'should not do anything' do
|
||||||
narrative.expects(:enqueue_timeout_job).with(user).never
|
narrative.expects(:enqueue_timeout_job).with(user).never
|
||||||
|
|
Loading…
Reference in New Issue