Merge pull request #5688 from tomhughes/spam-check-report
Make reports trigger a spam check on the reported user
This commit is contained in:
commit
094d9f9ba5
3 changed files with 41 additions and 1 deletions
|
@ -29,6 +29,8 @@ class ReportsController < ApplicationController
|
|||
@report.issue.reopen unless @report.issue.open?
|
||||
@report.issue.save!
|
||||
|
||||
@report.issue.reported_user&.spam_check
|
||||
|
||||
redirect_to helpers.reportable_url(@report.issue.reportable), :notice => t(".successful_report")
|
||||
else
|
||||
flash.now[:notice] = t(".provide_details")
|
||||
|
|
|
@ -359,7 +359,7 @@ class User < ApplicationRecord
|
|||
trace_score = traces.size * 50
|
||||
diary_entry_score = diary_entries.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
|
||||
diary_comment_score = diary_comments.visible.inject(0) { |acc, elem| acc + elem.body.spam_score }
|
||||
report_score = Report.where(:category => "spam", :issue => issues.with_status("open")).count * 20
|
||||
report_score = Report.where(:category => "spam", :issue => issues.with_status("open")).distinct.count(:user_id) * 20
|
||||
|
||||
score = description.spam_score / 4.0
|
||||
score += diary_entries.visible.where("created_at > ?", 1.day.ago).count * 10
|
||||
|
|
|
@ -111,4 +111,42 @@ class ReportsControllerTest < ActionDispatch::IntegrationTest
|
|||
|
||||
assert_equal 2, issue.reports.count
|
||||
end
|
||||
|
||||
def test_spam_reports_can_suspend
|
||||
target_user = create(:user)
|
||||
|
||||
session_for(create(:user))
|
||||
|
||||
post reports_path(:report => {
|
||||
:details => "Spammer",
|
||||
:category => "spam",
|
||||
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
|
||||
})
|
||||
assert_equal "active", target_user.reload.status
|
||||
|
||||
session_for(create(:user))
|
||||
|
||||
post reports_path(:report => {
|
||||
:details => "Spammer",
|
||||
:category => "spam",
|
||||
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
|
||||
})
|
||||
assert_equal "active", target_user.reload.status
|
||||
|
||||
post reports_path(:report => {
|
||||
:details => "Spammer",
|
||||
:category => "spam",
|
||||
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
|
||||
})
|
||||
assert_equal "active", target_user.reload.status
|
||||
|
||||
session_for(create(:user))
|
||||
|
||||
post reports_path(:report => {
|
||||
:details => "Spammer",
|
||||
:category => "spam",
|
||||
:issue => { :reportable_id => target_user.id, :reportable_type => "User" }
|
||||
})
|
||||
assert_equal "suspended", target_user.reload.status
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue