5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-23 04:06:21 +00:00

feat: poder bloquear en masa

This commit is contained in:
f 2024-03-04 17:14:46 -03:00
parent 1fe6199cea
commit c49182e278
No known key found for this signature in database
4 changed files with 26 additions and 17 deletions

View file

@ -9,7 +9,7 @@ class ActorModerationsController < ApplicationController
authorize actor_moderation authorize actor_moderation
# Crea una RemoteFlag si se envían los parámetros adecuados # 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}?") actor_moderation.public_send(:"#{actor_event}!") if actor_moderation.public_send(:"may_#{actor_event}?")
@ -37,7 +37,11 @@ class ActorModerationsController < ApplicationController
ActorModeration.transaction do ActorModeration.transaction do
actor_moderations.find_each do |actor_moderation| 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 end
end end
@ -48,10 +52,25 @@ class ActorModerationsController < ApplicationController
@actor_moderation ||= site.actor_moderations.find(params[:actor_moderation_id] || params[:id]) @actor_moderation ||= site.actor_moderations.find(params[:actor_moderation_id] || params[:id])
end end
def actor_moderation_params # @return [String]
params.require(:actor_moderation).permit(remote_flag_attributes: %i[message]).tap do |p| 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][:site_id] = actor_moderation.site_id
p[:remote_flag_attributes][:actor_id] = actor_moderation.actor_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 end
end end

View file

@ -1,13 +1,4 @@
-# Componente Botonera de Moderación de Cuentas (Remote_profile) -# 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 .d-flex.flex-row
- btn_class = 'btn-secondary' - btn_class = 'btn-secondary'
- ActorModeration.events.each do |actor_event| - ActorModeration.events.each do |actor_event|
@ -15,5 +6,4 @@
text: t(".text_#{actor_event}"), text: t(".text_#{actor_event}"),
path: public_send(:"site_actor_moderation_#{actor_event}_path", actor_moderation_id: actor_moderation), path: public_send(:"site_actor_moderation_#{actor_event}_path", actor_moderation_id: actor_moderation),
class: btn_class, class: btn_class,
disabled: !actor_moderation.public_send(:"may_#{actor_event}?"), disabled: !actor_moderation.public_send(:"may_#{actor_event}?")
params: form_params[actor_event]

View file

@ -107,7 +107,6 @@ en:
text_allow: Always approve text_allow: Always approve
text_block: Block text_block: Block
text_report: Report 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: actor_moderations:
show: show:
user: Username user: Username
@ -117,6 +116,7 @@ en:
profile_id: ID profile_id: ID
profile_published: Published profile_published: Published
profile_summary: Summary 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: moderation_queue:
everything: 'Select all' everything: 'Select all'
nothing: "There's nothing for this filter" nothing: "There's nothing for this filter"

View file

@ -106,7 +106,6 @@ es:
text_allow: Aprobar siempre text_allow: Aprobar siempre
text_block: Bloquear text_block: Bloquear
text_report: Reportar 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: actor_moderations:
show: show:
user: Nombre de usuarie user: Nombre de usuarie
@ -116,6 +115,7 @@ es:
profile_id: ID profile_id: ID
profile_published: Publicada profile_published: Publicada
profile_summary: Presentación 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: moderation_queue:
everything: 'Seleccionar todo' everything: 'Seleccionar todo'
nothing: 'No hay nada para este filtro' nothing: 'No hay nada para este filtro'