From 514842c9c65f2995c97d520e03045ede51cf29e5 Mon Sep 17 00:00:00 2001 From: Claire Date: Tue, 1 Mar 2022 19:37:47 +0100 Subject: [PATCH] Change old moderation strikes to be displayed in a separate page (#17566) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Change old moderation strikes to be displayed in a separate page Fixes #17552 This changes the moderation strikes displayed on `/auth/edit` to be those from the past 3 months, and make all moderation strikes targeting the current user available in `/disputes`. * Add short description of what the strikes page is for * Move link to list of strikes to “Account status” instead of navigation item * Normalize i18n file * Fix layout and styling of strikes link * Revert highlights_on regexp * Reintroduce account status summary - this way, “Account status” is never empty - account status is not necessarily bound to strikes, or recent strikes --- app/controllers/auth/registrations_controller.rb | 2 +- app/controllers/disputes/strikes_controller.rb | 6 +++++- app/models/account_warning.rb | 2 +- app/views/auth/registrations/_status.html.haml | 16 ++++++++++++++++ app/views/disputes/strikes/index.html.haml | 6 ++++++ config/locales/en.yml | 4 ++++ config/routes.rb | 2 +- 7 files changed, 34 insertions(+), 4 deletions(-) create mode 100644 app/views/disputes/strikes/index.html.haml diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb index 3b025838b0..1c3adbd786 100644 --- a/app/controllers/auth/registrations_controller.rb +++ b/app/controllers/auth/registrations_controller.rb @@ -127,7 +127,7 @@ class Auth::RegistrationsController < Devise::RegistrationsController end def set_strikes - @strikes = current_account.strikes.active.latest + @strikes = current_account.strikes.recent.latest end def require_not_suspended! diff --git a/app/controllers/disputes/strikes_controller.rb b/app/controllers/disputes/strikes_controller.rb index d41c5c727e..d85dcb4d57 100644 --- a/app/controllers/disputes/strikes_controller.rb +++ b/app/controllers/disputes/strikes_controller.rb @@ -1,7 +1,11 @@ # frozen_string_literal: true class Disputes::StrikesController < Disputes::BaseController - before_action :set_strike + before_action :set_strike, only: [:show] + + def index + @strikes = current_account.strikes.latest + end def show authorize @strike, :show? diff --git a/app/models/account_warning.rb b/app/models/account_warning.rb index 05d01942df..14d5ac3889 100644 --- a/app/models/account_warning.rb +++ b/app/models/account_warning.rb @@ -33,7 +33,7 @@ class AccountWarning < ApplicationRecord scope :latest, -> { order(id: :desc) } scope :custom, -> { where.not(text: '') } - scope :active, -> { where(overruled_at: nil).or(where('account_warnings.overruled_at >= ?', 30.days.ago)) } + scope :recent, -> { where('account_warnings.created_at >= ?', 3.months.ago) } def statuses Status.with_discarded.where(id: status_ids || []) diff --git a/app/views/auth/registrations/_status.html.haml b/app/views/auth/registrations/_status.html.haml index 3546510b21..68954a5daf 100644 --- a/app/views/auth/registrations/_status.html.haml +++ b/app/views/auth/registrations/_status.html.haml @@ -12,6 +12,22 @@ %h3= t('auth.status.account_status') +%p.hint + - if @user.account.suspended? + %span.negative-hint= t('user_mailer.warning.explanation.suspend') + - elsif @user.disabled? + %span.negative-hint= t('user_mailer.warning.explanation.disable') + - elsif @user.account.silenced? + %span.warning-hint= t('user_mailer.warning.explanation.silence') + - else + %span.positive-hint= t('auth.status.functional') + = render partial: 'account_warning', collection: @strikes +- if @user.account.strikes.exists? + %hr.spacer/ + + %p.muted-hint + = link_to t('auth.status.view_strikes'), disputes_strikes_path + %hr.spacer/ diff --git a/app/views/disputes/strikes/index.html.haml b/app/views/disputes/strikes/index.html.haml new file mode 100644 index 0000000000..6789fa4058 --- /dev/null +++ b/app/views/disputes/strikes/index.html.haml @@ -0,0 +1,6 @@ +- content_for :page_title do + = t('settings.strikes') + +%p= t('disputes.strikes.description_html', instance: Rails.configuration.x.local_domain) + += render partial: 'auth/registrations/account_warning', collection: @strikes diff --git a/config/locales/en.yml b/config/locales/en.yml index 536d1dbf65..a68d87d10e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -933,8 +933,10 @@ en: status: account_status: Account status confirming: Waiting for e-mail confirmation to be completed. + functional: Your account is fully operational. pending: Your application is pending review by our staff. This may take some time. You will receive an e-mail if your application is approved. redirecting_to: Your account is inactive because it is currently redirecting to %{acct}. + view_strikes: View past strikes against your account too_fast: Form submitted too fast, try again. trouble_logging_in: Trouble logging in? use_security_key: Use security key @@ -1010,6 +1012,7 @@ en: submit: Submit appeal associated_report: Associated report created_at: Dated + description_html: These are actions taken against your account and warnings that have been sent to you by the staff of %{instance}. recipient: Addressed to status: 'Post #%{id}' status_removed: Post already removed from system @@ -1391,6 +1394,7 @@ en: profile: Profile relationships: Follows and followers statuses_cleanup: Automated post deletion + strikes: Moderation strikes two_factor_authentication: Two-factor Auth webauthn_authentication: Security keys statuses: diff --git a/config/routes.rb b/config/routes.rb index a820f32adf..25eb1558fc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -165,7 +165,7 @@ Rails.application.routes.draw do end namespace :disputes do - resources :strikes, only: [:show] do + resources :strikes, only: [:show, :index] do resource :appeal, only: [:create] end end