about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/admin/reports/actions_controller.rb50
-rw-r--r--app/javascript/styles/mastodon/admin.scss37
-rw-r--r--app/models/admin/status_batch_action.rb12
-rw-r--r--app/views/admin/reports/_actions.html.haml27
-rw-r--r--app/views/admin/reports/show.html.haml57
5 files changed, 147 insertions, 36 deletions
diff --git a/app/controllers/admin/reports/actions_controller.rb b/app/controllers/admin/reports/actions_controller.rb
new file mode 100644
index 000000000..05a4fb63d
--- /dev/null
+++ b/app/controllers/admin/reports/actions_controller.rb
@@ -0,0 +1,50 @@
+# frozen_string_literal: true
+
+class Admin::Reports::ActionsController < Admin::BaseController
+  before_action :set_report
+
+  def create
+    authorize @report, :show?
+
+    case action_from_button
+    when 'delete'
+      status_batch_action = Admin::StatusBatchAction.new(
+        type: action_from_button,
+        status_ids: @report.status_ids,
+        current_account: current_account,
+        report_id: @report.id,
+        send_email_notification: !@report.spam?
+      )
+
+      status_batch_action.save!
+    when 'silence', 'suspend'
+      account_action = Admin::AccountAction.new(
+        type: action_from_button,
+        report_id: @report.id,
+        target_account: @report.target_account,
+        current_account: current_account,
+        send_email_notification: !@report.spam?
+      )
+
+      account_action.save!
+    end
+
+    redirect_to admin_reports_path
+  end
+
+  private
+
+  def set_report
+    @report = Report.find(params[:report_id])
+  end
+
+  def action_from_button
+    if params[:delete]
+      'delete'
+    elsif params[:silence]
+      'silence'
+    elsif params[:suspend]
+      'suspend'
+    end
+  end
+end
diff --git a/app/javascript/styles/mastodon/admin.scss b/app/javascript/styles/mastodon/admin.scss
index c20762fba..21669dded 100644
--- a/app/javascript/styles/mastodon/admin.scss
+++ b/app/javascript/styles/mastodon/admin.scss
@@ -1394,8 +1394,9 @@ a.sparkline {
     }
 
     &__button {
+      box-sizing: border-box;
       flex: 0 0 auto;
-      width: 100px;
+      width: 200px;
       padding: 15px;
       padding-right: 0;
 
@@ -1411,4 +1412,38 @@ a.sparkline {
       color: $dark-text-color;
     }
   }
+
+  @media screen and (max-width: 800px) {
+    border: 0;
+
+    &__item {
+      flex-direction: column;
+      border: 0;
+
+      &__button {
+        width: 100%;
+        padding: 15px 0;
+      }
+
+      &__description {
+        padding: 0;
+        padding-bottom: 15px;
+      }
+    }
+  }
+}
+
+.section-skip-link {
+  float: right;
+
+  a {
+    color: $ui-highlight-color;
+    text-decoration: none;
+
+    &:hover,
+    &:focus,
+    &:active {
+      text-decoration: underline;
+    }
+  }
 }
diff --git a/app/models/admin/status_batch_action.rb b/app/models/admin/status_batch_action.rb
index 85822214b..40f60f379 100644
--- a/app/models/admin/status_batch_action.rb
+++ b/app/models/admin/status_batch_action.rb
@@ -8,6 +8,12 @@ class Admin::StatusBatchAction
   attr_accessor :current_account, :type,
                 :status_ids, :report_id
 
+  attr_reader :send_email_notification
+
+  def send_email_notification=(value)
+    @send_email_notification = ActiveModel::Type::Boolean.new.cast(value)
+  end
+
   def save!
     process_action!
   end
@@ -55,7 +61,7 @@ class Admin::StatusBatchAction
       statuses.each { |status| Tombstone.find_or_create_by(uri: status.uri, account: status.account, by_moderator: true) } unless target_account.local?
     end
 
-    UserMailer.warning(target_account.user, @warning).deliver_later! if target_account.local?
+    UserMailer.warning(target_account.user, @warning).deliver_later! if warnable?
     RemovalWorker.push_bulk(status_ids) { |status_id| [status_id, { 'preserve' => target_account.local?, 'immediate' => !target_account.local? }] }
   end
 
@@ -82,6 +88,10 @@ class Admin::StatusBatchAction
     !report.nil?
   end
 
+  def warnable?
+    send_email_notification && target_account.local?
+  end
+
   def target_account
     @target_account ||= statuses.first.account
   end
diff --git a/app/views/admin/reports/_actions.html.haml b/app/views/admin/reports/_actions.html.haml
new file mode 100644
index 000000000..f3162b325
--- /dev/null
+++ b/app/views/admin/reports/_actions.html.haml
@@ -0,0 +1,27 @@
+= form_tag admin_report_actions_path(@report), method: :post do
+  .report-actions
+    .report-actions__item
+      .report-actions__item__button
+        = link_to t('admin.reports.mark_as_resolved'), resolve_admin_report_path(@report), method: :post, class: 'button'
+      .report-actions__item__description
+        = t('admin.reports.actions.resolve_description_html')
+    .report-actions__item
+      .report-actions__item__button
+        = button_tag t('admin.reports.delete_and_resolve'), name: :delete, class: 'button button--destructive'
+      .report-actions__item__description
+        = t('admin.reports.actions.delete_description_html')
+    .report-actions__item
+      .report-actions__item__button
+        = button_tag t('admin.accounts.silence'), name: :silence, class: 'button button--destructive'
+      .report-actions__item__description
+        = t('admin.reports.actions.silence_description_html')
+    .report-actions__item
+      .report-actions__item__button
+        = button_tag t('admin.accounts.suspend'), name: :suspend, class: 'button button--destructive'
+      .report-actions__item__description
+        = t('admin.reports.actions.suspend_description_html')
+    .report-actions__item
+      .report-actions__item__button
+        = link_to t('admin.accounts.custom'), new_admin_account_action_path(@report.target_account_id, report_id: @report.id), class: 'button'
+      .report-actions__item__description
+        = t('admin.reports.actions.other_description_html')
diff --git a/app/views/admin/reports/show.html.haml b/app/views/admin/reports/show.html.haml
index 4f513dd39..02c46e384 100644
--- a/app/views/admin/reports/show.html.haml
+++ b/app/views/admin/reports/show.html.haml
@@ -124,24 +124,30 @@
 - if @report.comment.present?
   %p= t('admin.reports.comment_description_html', name: content_tag(:strong, @report.account.username, class: 'username'))
 
-  .report-notes__item
-    = image_tag @report.account.avatar.url, class: 'report-notes__item__avatar'
-
-    .report-notes__item__header
-      %span.username
-        = link_to display_name(@report.account), admin_account_path(@report.account_id)
-      %time{ datetime: @report.created_at.iso8601, title: l(@report.created_at) }
-        - if @report.created_at.today?
-          = t('admin.report_notes.today_at', time: l(@report.created_at, format: :time))
-        - else
-          = l @report.created_at.to_date
+  .report-notes
+    .report-notes__item
+      = image_tag @report.account.avatar.url, class: 'report-notes__item__avatar'
+
+      .report-notes__item__header
+        %span.username
+          = link_to display_name(@report.account), admin_account_path(@report.account_id)
+        %time{ datetime: @report.created_at.iso8601, title: l(@report.created_at) }
+          - if @report.created_at.today?
+            = t('admin.report_notes.today_at', time: l(@report.created_at, format: :time))
+          - else
+            = l @report.created_at.to_date
 
-    .report-notes__item__content
-      = simple_format(h(@report.comment))
+      .report-notes__item__content
+        = simple_format(h(@report.comment))
 
 %hr.spacer/
 
-%h3= t 'admin.reports.statuses'
+%h3
+  = t 'admin.reports.statuses'
+  %small.section-skip-link
+    = link_to '#actions' do
+      = fa_icon 'angle-double-down'
+      = t('admin.reports.skip_to_actions')
 
 %p
   = t 'admin.reports.statuses_description_html'
@@ -156,8 +162,6 @@
       .batch-table__toolbar__actions
         - if !@statuses.empty? && @report.unresolved?
           = f.button safe_join([fa_icon('times'), t('admin.statuses.batch.remove_from_report')]), name: :remove_from_report, class: 'table-action-link', type: :submit
-          = f.button safe_join([fa_icon('trash'), t('admin.reports.delete_and_resolve')]), name: :delete, class: 'table-action-link', type: :submit, data: { confirm: t('admin.reports.are_you_sure') }
-        - else
     .batch-table__body
       - if @statuses.empty?
         = nothing_here 'nothing-here--under-tabs'
@@ -167,24 +171,9 @@
 - if @report.unresolved?
   %hr.spacer/
 
-  %p= t 'admin.reports.actions_description_html'
-
-  .report-actions
-    .report-actions__item
-      .report-actions__item__button
-        = link_to t('admin.accounts.silence'), new_admin_account_action_path(@report.target_account_id, type: 'silence', report_id: @report.id), class: 'button button--destructive'
-      .report-actions__item__description
-        = t('admin.reports.actions.silence_description_html')
-    .report-actions__item
-      .report-actions__item__button
-        = link_to t('admin.accounts.perform_full_suspension'), new_admin_account_action_path(@report.target_account_id, report_id: @report.id, type: 'suspend'), class: 'button button--destructive'
-      .report-actions__item__description
-        = t('admin.reports.actions.suspend_description_html')
-    .report-actions__item
-      .report-actions__item__button
-        = link_to t('admin.accounts.custom'), new_admin_account_action_path(@report.target_account_id, report_id: @report.id), class: 'button'
-      .report-actions__item__description
-        = t('admin.reports.actions.other_description_html')
+  %p#actions= t 'admin.reports.actions_description_html'
+
+  = render partial: 'admin/reports/actions'
 
 - unless @action_logs.empty?
   %hr.spacer/