5
0
Fork 0
mirror of https://0xacab.org/sutty/sutty synced 2024-11-22 08:16:21 +00:00

fix: no colgar toda la cola si algo falla en la api

This commit is contained in:
f 2024-03-08 14:42:27 -03:00
parent 4dff318030
commit 995c80fed1
No known key found for this signature in database
4 changed files with 32 additions and 1 deletions

View file

@ -11,11 +11,22 @@ class FediblockStatesController < ApplicationController
elsif fediblock_state.may_disable?
fediblock_state.disable!
end
flash[:success] = I18n.t('fediblock_states.action_on_several.success')
rescue Exception => e
ExceptionNotifier.notify_exception(e, data: { site: site.name })
flash.delete(:success)
flash[:error] = I18n.t('fediblock_states.action_on_several.error')
end
# Bloquear otras instancias
if custom_blocklist.present?
ActivityPub::InstanceModerationJob.perform_later(site: site, hostnames: custom_blocklist)
if ActivityPub::InstanceModerationJob.perform_now(site: site, hostnames: custom_blocklist)
flash[:success] = I18n.t('fediblock_states.action_on_several.custom_blocklist_success')
else
flash[:error] = I18n.t('fediblock_states.action_on_several.custom_blocklist_error')
end
end
redirect_to site_moderation_queue_path

View file

@ -14,6 +14,7 @@ class ActivityPub
end
instances = ActivityPub::Instance.where(hostname: hostnames)
success = true
Site.transaction do
# Crea todas las moderaciones de instancia con un estado por
@ -23,9 +24,15 @@ class ActivityPub
# idealmente son pocas instancias las que aparecen.
site.instance_moderations.find_or_create_by(instance: instance).tap do |instance_moderation|
instance_moderation.block! if instance_moderation.may_block?
# Notificar todos los errores sin detener la ejecución
rescue Exception => e
ExceptionNotifier.notify_exception(e, data: { site: site.name, instance_moderation: instance_moderation.id })
success = false
end
end
end
success
end
end
end

View file

@ -117,6 +117,12 @@ en:
text_report: Report
remote_flags:
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}."
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."
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_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'
nothing: "There's nothing for this filter"

View file

@ -116,6 +116,13 @@ es:
text_report: Reportar
remote_flags:
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}."
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."
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_error: "Hubo un error al agregar instancias personalizadas a la lista de bloqueo, ya recibimos el reporte y lo estaremos verificando."
actor_moderations:
moderation_queue:
everything: 'Seleccionar todo'
nothing: 'No hay nada para este filtro'