From c7aaee907b97525163e619a4934e78086d172343 Mon Sep 17 00:00:00 2001 From: Neil Lalonde Date: Wed, 16 Oct 2013 11:47:01 -0400 Subject: [PATCH] When system flags users as sockpuppets, show a reason in the admin flags ui --- app/assets/javascripts/admin/models/flagged_post.js | 3 ++- .../javascripts/admin/templates/flags.js.handlebars | 8 +++++++- app/services/spam_rules_enforcer.rb | 4 ++-- config/locales/server.en.yml | 3 +++ 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/app/assets/javascripts/admin/models/flagged_post.js b/app/assets/javascripts/admin/models/flagged_post.js index a6802e659..5fadbb69f 100644 --- a/app/assets/javascripts/admin/models/flagged_post.js +++ b/app/assets/javascripts/admin/models/flagged_post.js @@ -38,7 +38,8 @@ Discourse.FlaggedPost = Discourse.Post.extend({ r.push({ user: _this.userLookup[action.user_id], message: action.message, - permalink: action.permalink + permalink: action.permalink, + bySystemUser: (action.user_id === -1 ? true : false) }); } }); diff --git a/app/assets/javascripts/admin/templates/flags.js.handlebars b/app/assets/javascripts/admin/templates/flags.js.handlebars index 2138a4ac3..2fa9b2b1c 100644 --- a/app/assets/javascripts/admin/templates/flags.js.handlebars +++ b/app/assets/javascripts/admin/templates/flags.js.handlebars @@ -54,7 +54,13 @@ -
{{#link-to 'adminUser' user}}{{avatar user imageSize="small"}}{{/link-to}} {{message}}
+
+ {{#link-to 'adminUser' user}}{{avatar user imageSize="small"}}{{/link-to}} + {{message}} + {{#unless bySystemUser}} + + {{/unless}} +
diff --git a/app/services/spam_rules_enforcer.rb b/app/services/spam_rules_enforcer.rb index 3295c1dab..2a07b2822 100644 --- a/app/services/spam_rules_enforcer.rb +++ b/app/services/spam_rules_enforcer.rb @@ -40,9 +40,9 @@ class SpamRulesEnforcer def flag_sockpuppet_users system_user = Discourse.system_user - PostAction.act(system_user, @post, PostActionType.types[:spam]) rescue PostAction::AlreadyActed + PostAction.act(system_user, @post, PostActionType.types[:spam], message: I18n.t('flag_reason.sockpuppet')) rescue PostAction::AlreadyActed if (first_post = @post.topic.posts.by_post_number.first).try(:user).try(:new_user?) - PostAction.act(system_user, first_post, PostActionType.types[:spam]) rescue PostAction::AlreadyActed + PostAction.act(system_user, first_post, PostActionType.types[:spam], message: I18n.t('flag_reason.sockpuppet')) rescue PostAction::AlreadyActed end end diff --git a/config/locales/server.en.yml b/config/locales/server.en.yml index 14189b335..5a5a34157 100644 --- a/config/locales/server.en.yml +++ b/config/locales/server.en.yml @@ -1159,3 +1159,6 @@ en: fetch_failure: "Sorry, there has been an error while fetching the image." unknown_image_type: "Sorry, but the file you tried to upload doesn't appear to be an image." size_not_found: "Sorry, but we couldn't determine the size of the image. Maybe your image is corrupted?" + + flag_reason: + sockpuppet: "A new user created a topic, and another new user at the same IP address replied. See the flag_sockpuppets site setting."