mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 00:06:21 +00:00
parent
ef482aaedf
commit
f794e8057b
7 changed files with 53 additions and 49 deletions
|
@ -3,11 +3,10 @@
|
|||
class ActivityPub
|
||||
# Bloquea varias instancias de una sola vez
|
||||
class InstanceModerationJob < ApplicationJob
|
||||
self.priority = 50
|
||||
|
||||
# @param :site [Site]
|
||||
# @param :hostnames [Array<String>]
|
||||
def perform(site:, hostnames:)
|
||||
# @param :perform_remotely [Bool]
|
||||
def perform(site:, hostnames:, perform_remotely: true)
|
||||
# Crear las instancias que no existan todavía
|
||||
hostnames.each do |hostname|
|
||||
ActivityPub::Instance.find_or_create_by(hostname: hostname)
|
||||
|
@ -24,7 +23,13 @@ class ActivityPub
|
|||
site.instance_moderations.find_or_create_by(instance: instance)
|
||||
end
|
||||
|
||||
site.instance_moderations.where(instance_id: instances.ids).block_all!
|
||||
scope = site.instance_moderations.where(instance_id: instances.ids)
|
||||
|
||||
if perform_remotely
|
||||
scope.block_all!
|
||||
else
|
||||
scope.block_all_without_callbacks!
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -28,27 +28,23 @@ class ActorModeration < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
# Al permitir una cuenta se permiten todos los comentarios
|
||||
# Al permitir una cuenta no se permiten todos los comentarios
|
||||
# pendientes de moderación que ya hizo.
|
||||
event :allow do
|
||||
transitions from: %i[paused blocked reported], to: :allowed
|
||||
|
||||
before do
|
||||
allow_remotely!
|
||||
|
||||
site.activity_pubs.paused.where(actor_id: self.actor_id).approve_all!
|
||||
end
|
||||
end
|
||||
|
||||
# Al bloquear una cuenta se bloquean todos los comentarios
|
||||
# Al bloquear una cuenta no se bloquean todos los comentarios
|
||||
# pendientes de moderación que hizo.
|
||||
event :block do
|
||||
transitions from: %i[paused allowed], to: :blocked
|
||||
|
||||
before do
|
||||
block_remotely!
|
||||
|
||||
site.activity_pubs.paused.where(actor_id: self.actor_id).reject_all!
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -46,6 +46,19 @@ module AasmEventsConcern
|
|||
|
||||
success
|
||||
end
|
||||
|
||||
# Ejecuta la transición del evento en la base de datos sin
|
||||
# ejecutar los callbacks, sin modificar los items del scope que no
|
||||
# pueden transicionar.
|
||||
#
|
||||
# @return [Integer] Registros modificados
|
||||
define_singleton_method(:"#{event}_all_without_callbacks!") do
|
||||
aasm_event = self.aasm.events.find { |e| e.name == event }
|
||||
to_state = aasm_event.transitions.map(&:to).first
|
||||
from_states = aasm_event.transitions.map(&:from)
|
||||
|
||||
self.unscope(where: :aasm_state).where(aasm_state: from_states).update_all(aasm_state: to_state, updated_at: Time.now)
|
||||
end
|
||||
end
|
||||
|
||||
# Envía notificación de errores
|
||||
|
|
|
@ -30,15 +30,9 @@ class FediblockState < ApplicationRecord
|
|||
# Bloquear todos las instancias de este Fediblock
|
||||
enable_remotely! list_names(fediblock.hostnames)
|
||||
|
||||
# Al actualizar el estado en masa garantizamos que las
|
||||
# instancias que ya existen queden sincronizadas con el bloqueo
|
||||
# en masa que acabamos de hacer.
|
||||
instance_ids = fediblock.instances.ids
|
||||
site.instance_moderations.where(instance_id: instance_ids).block_all!
|
||||
|
||||
# Luego esta tarea crea las que falten e ignora las que ya se
|
||||
# bloquearon.
|
||||
ActivityPub::InstanceModerationJob.perform_now(site: site, hostnames: fediblock.hostnames)
|
||||
ActivityPub::InstanceModerationJob.perform_now(site: site, hostnames: fediblock.hostnames, perform_remotely: false)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -59,7 +53,7 @@ class FediblockState < ApplicationRecord
|
|||
# Pausar todas las moderaciones de las instancias que no estén
|
||||
# bloqueadas por otros fediblocks.
|
||||
instance_ids = ActivityPub::Instance.where(hostname: unique_hostnames).ids
|
||||
site.instance_moderations.where(instance_id: instance_ids).pause_all!
|
||||
site.instance_moderations.where(instance_id: instance_ids).pause_all_without_callbacks!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -25,27 +25,23 @@ class InstanceModeration < ApplicationRecord
|
|||
end
|
||||
end
|
||||
|
||||
# Al permitir, también permitimos todes les actores que no hayan
|
||||
# tenido acciones de moderación.
|
||||
# Al permitir, solo bloqueamos la instancia, sin modificar el estado
|
||||
# de les actores y comentarios retroactivamente.
|
||||
event :allow do
|
||||
transitions from: %i[paused blocked], to: :allowed
|
||||
|
||||
before do
|
||||
allow_remotely!
|
||||
|
||||
site.actor_moderations.paused.where(actor_id: actor_ids).allow_all!
|
||||
end
|
||||
end
|
||||
|
||||
# Al bloquear, también bloqueamos a todes les actores que no hayan
|
||||
# tenido acciones de moderación.
|
||||
# Al bloquear, solo bloqueamos la instancia, sin modificar el estado
|
||||
# de les actores y comentarios retroactivamente.
|
||||
event :block do
|
||||
transitions from: %i[paused allowed], to: :blocked
|
||||
|
||||
before do
|
||||
block_remotely!
|
||||
|
||||
site.actor_moderations.paused.where(actor_id: actor_ids).block_all!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -132,38 +132,38 @@ en:
|
|||
error: "There was an error while reporting the comment. We received a report and will be acting on it soon."
|
||||
actor_moderations:
|
||||
action_on_several:
|
||||
success: "Several accounts have changed moderation state. You can find them using the filters on the Accounts section."
|
||||
success: "Several accounts have changed moderation state. You can find them using the filters on the Accounts section. No action was performed over existing Comments."
|
||||
error: "There was an error while changing moderation state. We received a report and will be acting on it soon."
|
||||
pause:
|
||||
success: "Account paused. All of their comments will need to be moderated individually on the Comments section."
|
||||
success: "Account paused. No action was performed on existing Comments."
|
||||
error: "There was an error while pausing the account. We received a report and will be acting on it soon."
|
||||
allow:
|
||||
success: "Account allowed. All of their comments will be approved automatically. Any pending comments have been approved."
|
||||
success: "Account allowed. All of their comments from now on will be approved automatically. No action was performed over existing Comments."
|
||||
error: "There was an error while allowing the account. We received a report and will be acting on it soon."
|
||||
block:
|
||||
success: "Account blocked. All of their comments will be rejected automatically. Any pending comments have been rejected. If you want to report it to their instance, please use the Report button."
|
||||
success: "Account blocked. All of their comments from now on will be rejected automatically. No action was performed over existing Comments. If you want to report it to their instance, please use the Report button."
|
||||
error: "There was an error while blocking the account. We received a report and will be acting on it soon."
|
||||
report:
|
||||
success: "Account reported."
|
||||
error: "There was an error while reporting the account. We received a report and will be acting on it soon."
|
||||
instance_moderations:
|
||||
action_on_several:
|
||||
success: "Several instances have changed moderation state. You can find them using the filters on the Instances section."
|
||||
success: "Several instances have changed moderation state. You can find them using the filters on the Instances section. No action was performed over existing Accounts and Comments."
|
||||
error: "There was an error while changing moderation state. We received a report and will be acting on it soon."
|
||||
pause:
|
||||
success: "Instance paused. All of their comments and accounts will need to be moderated individually."
|
||||
success: "Instance paused. All of their comments and accounts from now on will need to be moderated individually. No action was performed over existing Accounts and Comments."
|
||||
error: "There was an error while pausing the instance. We received a report and will be acting on it soon."
|
||||
allow:
|
||||
success: "Instance allowed. All of their comments and accounts will be approved automatically. Any pending comments and accounts have been also approved."
|
||||
success: "Instance allowed. All of their comments and accounts from now on will be approved automatically. No action was performed over existing Accounts and Comments."
|
||||
error: "There was an error while allowing the instance. We received a report and will be acting on it soon."
|
||||
block:
|
||||
success: "Instance blocked. All of their comments and accounts will be rejected automatically. Any pending comments and accounts have been also rejected."
|
||||
success: "Instance blocked. All of their comments and accounts from now on will be rejected automatically. No action was performed over existing Accounts and Comments."
|
||||
error: "There was an error while blocking the instance. We received a report and will be acting on it soon."
|
||||
fediblock_states:
|
||||
action_on_several:
|
||||
success: "Blocklists have been enabled, you can find their instances by filtering by Blocked. Any pending account from these instances has also been blocked. You can approve them individually on the Accounts section."
|
||||
success: "Blocklists have been enabled, you can find their instances by filtering by Blocked. You can approve them individually on the Accounts section. No action was performed over existing Accounts and Comments."
|
||||
error: "There was an error while enabling or disabling blocklists. We received a report and will be acting on it soon."
|
||||
custom_blocklist_success: "Custom blocklist has been added, you can find the instances by filtering by Blocked. Any pending account from these instances has also been blocked. You can approve them individually on the Accounts section."
|
||||
custom_blocklist_success: "Custom blocklist has been added, you can find the instances by filtering by Blocked. No action was performed over existing Accounts and Comments."
|
||||
custom_blocklist_error: "There was an error while adding a custom blocklist. We received a report and will be acting on it soon."
|
||||
moderation_queue:
|
||||
everything: 'Select all'
|
||||
|
|
|
@ -131,38 +131,38 @@ es:
|
|||
error: "No se puedo reportar el comentario. Hemos recibido el reporte y lo estaremos verificando."
|
||||
actor_moderations:
|
||||
action_on_several:
|
||||
success: "Se ha modificado el estado de moderación de varias cuentas. Podés encontrarlas usando los filtros en la sección Cuentas."
|
||||
success: "Se ha modificado el estado de moderación de varias cuentas. Podés encontrarlas usando los filtros en la sección Cuentas. No se modificaron comentarios pre-existentes."
|
||||
error: "Hubo un error al modificar el estado de moderación de varias cuentas. Hemos recibido el reporte y lo estaremos verificando."
|
||||
pause:
|
||||
success: "Cuenta pausada. Todos los comentarios que haga necesitan ser aprobados manualmente en la sección Comentarios."
|
||||
success: "Cuenta pausada. Todos los comentarios que haga necesitan ser aprobados manualmente en la sección Comentarios. No se modificaron comentarios pre-existentes."
|
||||
error: "No se pudo pausar la cuenta. Hemos recibido el reporte y lo estaremos verificando."
|
||||
allow:
|
||||
success: "Cuenta permitida. Todos los comentarios que haga serán aprobados inmediatamente. Todos los comentarios pendientes de moderación fueron aprobados."
|
||||
success: "Cuenta permitida. Todos los comentarios que haga serán aprobados inmediatamente. No se modificaron comentarios pre-existentes."
|
||||
error: "No se pudo permitir la cuenta. Hemos recibido el reporte y lo estaremos verificando."
|
||||
block:
|
||||
success: "Cuenta bloqueada. Todos los comentarios que haga serán rechazados inmediatamente. Todos los comentarios pendientes de moderación fueron rechazados. Si querés reportarla a su instancia, podés usar el botón Reportar."
|
||||
success: "Cuenta bloqueada. Todos los comentarios que haga serán rechazados inmediatamente. Si querés reportarla a su instancia, podés usar el botón Reportar. No se modificaron comentarios pre-existentes."
|
||||
error: "No se pudo bloquear la cuenta. Hemos recibido el reporte y lo estaremos verificando."
|
||||
report:
|
||||
success: "Cuenta reportada a su instancia."
|
||||
error: "No se pudo reportar la cuenta. Hemos recibido el reporte y lo estaremos verificando."
|
||||
instance_moderations:
|
||||
action_on_several:
|
||||
success: "Se ha modificado el estado de moderación de varias instancias. Podés encontrarlas usando los filtros en la sección Instancias."
|
||||
success: "Se ha modificado el estado de moderación de varias instancias. Podés encontrarlas usando los filtros en la sección Instancias. No se modificaron cuentas y comentarios pre-existentes."
|
||||
error: "Hubo un error al modificar el estado de moderación de varias instancias. Hemos recibido el reporte y lo estaremos verificando."
|
||||
pause:
|
||||
success: "Instancia pausada. Todos los comentarios y cuentas de esta instancia necesitan ser aprobados manualmente. No se ha modificado el estado de moderación de cuentas y comentarios pre-existentes."
|
||||
success: "Instancia pausada. A partir de ahora, todos los comentarios y cuentas de esta instancia necesitan ser aprobados manualmente. No se ha modificado el estado de moderación de cuentas ni comentarios pre-existentes."
|
||||
error: "No se pudo pausar la instancia. Hemos recibido el reporte y lo estaremos verificando."
|
||||
allow:
|
||||
success: "Instancia permitida. Todos los comentarios y cuentas pendientes de moderación fueron aprobados y los próximos serán aprobados inmediatamente."
|
||||
success: "Instancia permitida. A partir de ahora, todos los comentarios y cuentas pendientes serán aprobados inmediatamente. No se modificaron cuentas ni comentarios pre-existentes."
|
||||
error: "No se pudo permitir la instancia. Hemos recibido el reporte y lo estaremos verificando."
|
||||
block:
|
||||
success: "Instancia bloqueada. Todos los comentarios y cuentas serán rechazados inmediatamente. Todos los comentarios y cuentas pendientes de moderación fueron rechazados."
|
||||
success: "Instancia bloqueada. A partir de ahora, todos los comentarios y cuentas serán rechazados inmediatamente. No se modificaron cuentas ni comentarios pre-existentes."
|
||||
error: "No se pudo bloquear la instancia. Hemos recibido el reporte y lo estaremos verificando."
|
||||
fediblock_states:
|
||||
action_on_several:
|
||||
success: "Se habilitaron las listas de bloqueo, podés encontrar las instancias filtrando por Bloqueadas. Todas las cuentas de estas instancias pendientes de moderación han sido bloqueadas. Podés activarlas individualmente en la sección Cuentas."
|
||||
success: "Se habilitaron las listas de bloqueo, podés encontrar las instancias filtrando por Bloqueadas. Podés activarlas individualmente en la sección Cuentas. No se modificaron cuentas ni comentarios pre-existentes."
|
||||
error: "Hubo un error al activar o desactivar listas de bloqueo, ya recibimos el reporte y lo estaremos verificando."
|
||||
custom_blocklist_success: "Se agregaron las instancias personalizadas a la lista de bloqueo, podés encontrarlas filtrando por Bloqueadas. Todas las cuentas de estas instancias pendientes de moderación han sido bloqueadas. Podés aprobarlas individualmente en la sección Cuentas."
|
||||
custom_blocklist_success: "Se agregaron las instancias personalizadas a la lista de bloqueo, podés encontrarlas filtrando por Bloqueadas. Podés aprobarlas individualmente en la sección Cuentas. No se modificaron cuentas ni comentarios pre-existentes."
|
||||
custom_blocklist_error: "Hubo un error al agregar instancias personalizadas a la lista de bloqueo, ya recibimos el reporte y lo estaremos verificando."
|
||||
moderation_queue:
|
||||
everything: 'Seleccionar todo'
|
||||
|
|
Loading…
Reference in a new issue