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:
Blake Erickson
2020-08-03 19:38:04 -06:00
parent 8246b611ac
commit 18dad4cfbd
4 changed files with 25 additions and 5 deletions

View File

@ -474,7 +474,14 @@ module DiscourseNarrativeBot
def missing_flag
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
reply_to(@post, I18n.t("#{I18N_KEY}.flag.not_found", i18n_post_args)) unless @data[:attempted]