From c49182e278edd723a29fcad7671a138ee1f1d623 Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Mar 2024 17:14:46 -0300 Subject: [PATCH] feat: poder bloquear en masa --- .../actor_moderations_controller.rb | 27 ++++++++++++++++--- app/views/components/_profiles_btn_box.haml | 12 +-------- config/locales/en.yml | 2 +- config/locales/es.yml | 2 +- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/app/controllers/actor_moderations_controller.rb b/app/controllers/actor_moderations_controller.rb index eadc2165..2d834015 100644 --- a/app/controllers/actor_moderations_controller.rb +++ b/app/controllers/actor_moderations_controller.rb @@ -9,7 +9,7 @@ class ActorModerationsController < ApplicationController authorize actor_moderation # Crea una RemoteFlag si se envían los parámetros adecuados - actor_moderation.update(actor_moderation_params) if actor_event == :report + actor_moderation.update(actor_moderation_params(actor_moderation)) if actor_event == :report actor_moderation.public_send(:"#{actor_event}!") if actor_moderation.public_send(:"may_#{actor_event}?") @@ -37,7 +37,11 @@ class ActorModerationsController < ApplicationController ActorModeration.transaction do actor_moderations.find_each do |actor_moderation| - actor_moderation.public_send(method) if actor_moderation.public_send(may) + next unless actor_moderation.public_send(may) + + actor_moderation.update(actor_moderation_params(actor_moderation)) if action == :report + + actor_moderation.public_send(method) end end end @@ -48,10 +52,25 @@ class ActorModerationsController < ApplicationController @actor_moderation ||= site.actor_moderations.find(params[:actor_moderation_id] || params[:id]) end - def actor_moderation_params - params.require(:actor_moderation).permit(remote_flag_attributes: %i[message]).tap do |p| + # @return [String] + def panel_actor_mention + @panel_actor_mention ||= ENV.fetch('PANEL_ACTOR_MENTION', '@sutty@sutty.nl') + end + + # @return [Hash] + def actor_moderation_params(actor_moderation) + { remote_flag_attributes: { id: actor_moderation.remote_flag_id, message: '' } }.tap do |p| p[:remote_flag_attributes][:site_id] = actor_moderation.site_id p[:remote_flag_attributes][:actor_id] = actor_moderation.actor_id + + I18n.available_locales.each do |locale| + p[:remote_flag_attributes][:message].tap do |m| + m += I18n.t(locale) + m += ': ' + m += I18n.t('actor_moderations.report_message', locale: locale, panel_actor_mention: panel_actor_mention) + m += '\n\n' + end + end end end end diff --git a/app/views/components/_profiles_btn_box.haml b/app/views/components/_profiles_btn_box.haml index 3ec95e59..073c142e 100644 --- a/app/views/components/_profiles_btn_box.haml +++ b/app/views/components/_profiles_btn_box.haml @@ -1,13 +1,4 @@ -# Componente Botonera de Moderación de Cuentas (Remote_profile) - -- form_params = {} -- form_params[:report] = { actor_moderation: { remote_flag_attributes: { message: '' } } } -- I18n.available_locales.each do |locale| - - form_params[:report][:actor_moderation][:remote_flag_attributes][:message] += t(locale) - - form_params[:report][:actor_moderation][:remote_flag_attributes][:message] += ': ' - - form_params[:report][:actor_moderation][:remote_flag_attributes][:message] += t('.report_message', locale: locale, panel_actor_mention: ENV.fetch('PANEL_ACTOR_MENTION') { '@sutty@sutty.nl' }) - - form_params[:report][:actor_moderation][:remote_flag_attributes][:message] += '\n\n' - .d-flex.flex-row - btn_class = 'btn-secondary' - ActorModeration.events.each do |actor_event| @@ -15,5 +6,4 @@ text: t(".text_#{actor_event}"), path: public_send(:"site_actor_moderation_#{actor_event}_path", actor_moderation_id: actor_moderation), class: btn_class, - disabled: !actor_moderation.public_send(:"may_#{actor_event}?"), - params: form_params[actor_event] + disabled: !actor_moderation.public_send(:"may_#{actor_event}?") diff --git a/config/locales/en.yml b/config/locales/en.yml index a10b9f3a..fe8798f4 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -107,7 +107,6 @@ en: text_allow: Always approve text_block: Block text_report: Report - report_message: "Hi! Someone using Sutty CMS reported this account on your instance. We don't have support for customized report messages yet, but we will soon. You can reach us at %{panel_actor_mention}." actor_moderations: show: user: Username @@ -117,6 +116,7 @@ en: profile_id: ID profile_published: Published profile_summary: Summary + report_message: "Hi! Someone using Sutty CMS reported this account on your instance. We don't have support for customized report messages yet, but we will soon. You can reach us at %{panel_actor_mention}." moderation_queue: everything: 'Select all' nothing: "There's nothing for this filter" diff --git a/config/locales/es.yml b/config/locales/es.yml index f5487e47..e22fdf57 100644 --- a/config/locales/es.yml +++ b/config/locales/es.yml @@ -106,7 +106,6 @@ es: text_allow: Aprobar siempre text_block: Bloquear text_report: Reportar - report_message: "¡Hola! Une usuarie de Sutty CMS reportó esta cuenta en tu instancia. Todavía no tenemos soporte para mensajes personalizados. Podés contactarnos en %{panel_actor_mention}." actor_moderations: show: user: Nombre de usuarie @@ -116,6 +115,7 @@ es: profile_id: ID profile_published: Publicada profile_summary: Presentación + report_message: "¡Hola! Une usuarie de Sutty CMS reportó esta cuenta en tu instancia. Todavía no tenemos soporte para mensajes personalizados. Podés contactarnos en %{panel_actor_mention}." moderation_queue: everything: 'Seleccionar todo' nothing: 'No hay nada para este filtro'