Skip to content
Extraits de code Groupes Projets
Valider 1748d3b9 rédigé par Lukas Matt's avatar Lukas Matt
Parcourir les fichiers

It is now possible to report comments

* Renamed PostReport to Report
* Added report button to SPV
* Updated rspec

refs diaspora/diaspora#4732
refs diaspora/diaspora#4710
refs diaspora/diaspora#4711
refs diaspora/diaspora#4517
parent ee6212c6
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
.span-24
= render :partial => 'admins/admin_bar'
.span-24.last
%h1
= t('post_report.title')
%div#post_report
- @post_report.each do |report|
%div.content
%span
= raw t('post_report.post_label', title: link_to(post_page_title(Post.find_by_id(report.post_id)), post_path(report.post_id)))
%span
= raw t('post_report.reported_label', person: link_to(report.user_id, user_profile_path(report.user_id)))
%span
= t('post_report.reason_label', text: report.text)
%div.options
%span
= link_to t('post_report.review_link'), post_report_path(report.post_id), method: :put
%span
= link_to t('post_report.delete_link'), post_report_path(report.post_id), method: :delete
%div.clear
<%= t('notifier.post_report_email.body') %>
.span-24
= render :partial => 'admins/admin_bar'
.span-24.last
%h1
= t('report.title')
%div#report
- @report.each do |r|
%div.content
%span
= report_content(r.post_id, r.post_type)
%span
= raw t('report.reported_label', person: link_to(r.user_id, user_profile_path(r.user_id)))
%span
= t('report.reason_label', text: r.text)
%div.options
%span
= link_to t('report.review_link'), report_path(r.post_id, :type => r.post_type), method: :put
%span
= link_to t('report.delete_link'), report_path(r.post_id, :type => r.post_type), method: :delete
%div.clear
<%= t('notifier.report_email.body', url: resource[:url], type: resource[:type], id: resource[:id]) %>
module Workers module Workers
module Mail module Mail
class PostReportWorker < Base class ReportWorker < Base
sidekiq_options queue: :mail sidekiq_options queue: :mail
def perform def perform(type, id)
PostReportMailer.new_report ReportMailer.new_report(type, id)
end end
end end
end end
......
...@@ -99,7 +99,7 @@ en: ...@@ -99,7 +99,7 @@ en:
user_search: "User Search" user_search: "User Search"
weekly_user_stats: "Weekly User Stats" weekly_user_stats: "Weekly User Stats"
pod_stats: "Pod Stats" pod_stats: "Pod Stats"
post_report: "Reported Posts" report: "Reports"
correlations: "Correlations" correlations: "Correlations"
sidekiq_monitor: "Sidekiq monitor" sidekiq_monitor: "Sidekiq monitor"
correlations: correlations:
...@@ -736,9 +736,23 @@ en: ...@@ -736,9 +736,23 @@ en:
confirm_email: confirm_email:
subject: "Please activate your new email address %{unconfirmed_email}" subject: "Please activate your new email address %{unconfirmed_email}"
click_link: "To activate your new email address %{unconfirmed_email}, please follow this link:" click_link: "To activate your new email address %{unconfirmed_email}, please follow this link:"
post_report_email: report_email:
subject: "A new post was marked as offensive" subject: "A new %{type} was marked as offensive"
body: "Please review as soon as possible!" body: |-
Hello,
the %{type} with ID %{id} was marked as offensive.
[%{url}][1]
Please review as soon as possible!
Cheers,
The diaspora* email robot!
[1]: %{url}
accept_invite: "Accept Your diaspora* invite!" accept_invite: "Accept Your diaspora* invite!"
invited_you: "%{name} invited you to diaspora*" invited_you: "%{name} invited you to diaspora*"
invite: invite:
...@@ -868,9 +882,10 @@ en: ...@@ -868,9 +882,10 @@ en:
other: "%{count} photos by %{author}" other: "%{count} photos by %{author}"
reshare_by: "Reshare by %{author}" reshare_by: "Reshare by %{author}"
post_report: report:
title: "Marked Reports Overview" title: "Reports Overview"
post_label: "<b>Post</b>: %{title}" post_label: "<b>Post</b>: %{title}"
comment_label: "<b>Comment</b>:<br>%{data}"
reported_label: "<b>Reported by</b> %{person}" reported_label: "<b>Reported by</b> %{person}"
reason_label: "Reason: %{text}" reason_label: "Reason: %{text}"
review_link: "Mark as reviewed" review_link: "Mark as reviewed"
......
...@@ -6,11 +6,11 @@ ...@@ -6,11 +6,11 @@
en: en:
javascripts: javascripts:
confirm_dialog: "Are you sure?" confirm_dialog: "Are you sure?"
post_report_prompt: "Please enter a reason:" report_prompt: "Please enter a reason:"
post_report_prompt_default: "offensive content" report_prompt_default: "offensive content"
delete: "Delete" delete: "Delete"
ignore: "Ignore" ignore: "Ignore"
post_report: "Report" report: "Report"
ignore_user: "Ignore this user?" ignore_user: "Ignore this user?"
and: "and" and: "and"
comma: "," comma: ","
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
require 'sidekiq/web' require 'sidekiq/web'
Diaspora::Application.routes.draw do Diaspora::Application.routes.draw do
resources :post_report, :except => [:edit] resources :report, :except => [:edit, :new]
if Rails.env.production? if Rails.env.production?
mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin' mount RailsAdmin::Engine => '/admin_panel', :as => 'rails_admin'
......
class AddPostTypeToPostReport < ActiveRecord::Migration
def change
add_column :post_reports, :post_type, :string, :null => false, :after => :post_id
end
end
class RenamePostReportToReport < ActiveRecord::Migration
def self.up
rename_table :post_reports, :reports
end
def self.down
rename_table :reports, :post_reports
end
end
...@@ -410,6 +410,18 @@ ActiveRecord::Schema.define(:version => 20140308154022) do ...@@ -410,6 +410,18 @@ ActiveRecord::Schema.define(:version => 20140308154022) do
add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories" add_index "rails_admin_histories", ["item", "table", "month", "year"], :name => "index_rails_admin_histories"
create_table "reports", :force => true do |t|
t.integer "post_id", :null => false
t.string "post_type", :null => false
t.string "user_id"
t.boolean "reviewed", :default => false
t.text "text"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end
add_index "reports", ["post_id"], :name => "index_post_reports_on_post_id"
create_table "roles", :force => true do |t| create_table "roles", :force => true do |t|
t.integer "person_id" t.integer "person_id"
t.string "name" t.string "name"
......
require 'spec_helper' require 'spec_helper'
describe PostReportController do describe ReportController do
before do before do
sign_in alice sign_in alice
@message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id) @message = alice.post(:status_message, :text => "hey", :to => alice.aspects.first.id)
@comment = alice.comment!(@message, "flying pigs, everywhere")
end end
describe '#index' do describe '#index' do
...@@ -26,32 +27,61 @@ describe PostReportController do ...@@ -26,32 +27,61 @@ describe PostReportController do
end end
describe '#create' do describe '#create' do
context 'report offensive content' do let(:comment_hash) {
{:text =>"facebook, is that you?",
:post_id =>"#{@post.id}"}
}
context 'report offensive post' do
it 'succeeds' do it 'succeeds' do
put :create, :post_id => @message.id, :text => 'offensive content' put :create, :id => @message.id, :type => 'post', :text => 'offensive content'
response.status.should == 200 response.status.should == 200
PostReport.exists?(:post_id => @message.id).should be_true Report.exists?(:post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'report offensive comment' do
it 'succeeds' do
put :create, :id => @comment.id, :type => 'comment', :text => 'offensive content'
response.status.should == 200
Report.exists?(:post_id => @comment.id, :post_type => 'comment').should be_true
end end
end end
end end
describe '#update' do describe '#update' do
context 'mark report as user' do context 'mark post report as user' do
it 'is behind redirect_unless_admin' do
put :update, :id => @message.id, :type => 'post'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'mark comment report as user' do
it 'is behind redirect_unless_admin' do it 'is behind redirect_unless_admin' do
put :update, :id => @message.id put :update, :id => @comment.id, :type => 'comment'
response.should redirect_to stream_path response.should redirect_to stream_path
PostReport.where(:reviewed => false, :post_id => @message.id).should be_true Report.where(:reviewed => false, :post_id => @comment.id, :post_type => 'comment').should be_true
end end
end end
context 'mark report as admin' do context 'mark post report as admin' do
before do before do
Role.add_admin(alice.person) Role.add_admin(alice.person)
end end
it 'succeeds' do it 'succeeds' do
put :update, :id => @message.id put :update, :id => @message.id, :type => 'post'
response.status.should == 302 response.status.should == 302
PostReport.where(:reviewed => true, :post_id => @message.id).should be_true Report.where(:reviewed => true, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'mark comment report as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
put :update, :id => @comment.id, :type => 'comment'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @comment.id, :post_type => 'comment').should be_true
end end
end end
end end
...@@ -59,9 +89,16 @@ describe PostReportController do ...@@ -59,9 +89,16 @@ describe PostReportController do
describe '#destroy' do describe '#destroy' do
context 'destroy post as user' do context 'destroy post as user' do
it 'is behind redirect_unless_admin' do it 'is behind redirect_unless_admin' do
delete :destroy, :id => @message.id delete :destroy, :id => @message.id, :type => 'post'
response.should redirect_to stream_path response.should redirect_to stream_path
PostReport.where(:reviewed => false, :post_id => @message.id).should be_true Report.where(:reviewed => false, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'destroy comment as user' do
it 'is behind redirect_unless_admin' do
delete :destroy, :id => @comment.id, :type => 'comment'
response.should redirect_to stream_path
Report.where(:reviewed => false, :post_id => @comment.id, :post_type => 'comment').should be_true
end end
end end
...@@ -70,9 +107,19 @@ describe PostReportController do ...@@ -70,9 +107,19 @@ describe PostReportController do
Role.add_admin(alice.person) Role.add_admin(alice.person)
end end
it 'succeeds' do it 'succeeds' do
delete :destroy, :id => @message.id delete :destroy, :id => @message.id, :type => 'post'
response.status.should == 302
Report.where(:reviewed => true, :post_id => @message.id, :post_type => 'post').should be_true
end
end
context 'destroy comment as admin' do
before do
Role.add_admin(alice.person)
end
it 'succeeds' do
delete :destroy, :id => @comment.id, :type => 'comment'
response.status.should == 302 response.status.should == 302
PostReport.where(:reviewed => true, :post_id => @message.id).should be_true Report.where(:reviewed => true, :post_id => @comment.id, :post_type => 'comment').should be_true
end end
end end
end end
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter