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

Merge branch 'issue-17549' into production.panel.sutty.nl

This commit is contained in:
f 2024-11-13 16:38:23 -03:00
commit fbaa67ab61
No known key found for this signature in database
9 changed files with 90 additions and 3 deletions

View file

@ -0,0 +1,23 @@
# frozen_string_literal: true
class ActivityPub
# Notifica a les moderadores cuando un sitio fue reportado.
class ActorFlaggedMailer < ::ApplicationMailer
# Envía correo a cada moderadore en su idioma
#
# @param :site_id [String,Integer]
# @param :site_name [String]
# @param :content [String]
def notify_moderators
Usuarie.moderators.pluck(:lang, :email).group_by(&:first).transform_values do |value|
value.last
end.each_pair do |lang, emails|
I18n.with_locale(lang) do
emails.each do |email|
mail to: email, subject: I18n.t('activity_pub.actor_flagged_mailer.notify_moderators.subject')
end
end
end
end
end
end

View file

@ -2,6 +2,16 @@
class ActivityPub
class Activity
class Flag < ActivityPub::Activity; end
class Flag < ActivityPub::Activity
# Notifica a todes les moderadores
def update_activity_pub_state!
ActivityPub::ActorFlaggedMailer.with(
content: content['content'],
object: content['object'],
actor: content['actor'],
site_id: activity_pub.site_id
).notify_moderators.deliver_later
end
end
end
end

View file

@ -0,0 +1,11 @@
# frozen_string_literal: true
class ActivityPub
module ModeratorConcern
extend ActiveSupport::Concern
included do
scope :moderators, ->() { where(moderator: true) }
end
end
end

View file

@ -3,6 +3,7 @@
# Usuarie de la plataforma
class Usuarie < ApplicationRecord
include Usuarie::Consent
include ActivityPub::ModeratorConcern
devise :invitable, :database_authenticatable,
:recoverable, :rememberable, :validatable,

View file

@ -0,0 +1,18 @@
= t('.content', site_id: params[:site_id])
= Terminal::Table.new do |table|
- if (actor = params[:actor].presence).present?
- table << [ t('.actor') ]
- table.add_separator
- table << [ actor ]
- table.add_separator
- if (content = sanitize(params[:content])).present?
- table << [ word_wrap(content, line_width: 50) ]
- table.add_separator
- if (uris = [params[:object]].flatten).present?
- table << [ t('.uris') ]
- table.add_separator
- uris.each do |uri|
- table << [ uri ]

View file

@ -120,6 +120,13 @@ en:
confirm_report: "Send report to the remote instance? This action will also block the account."
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}."
activity_pub:
actor_flagged_mailer:
notify_moderators:
subject: "A site has been reported"
content: "The site with id %{site_id} has been reported. Please review the report ASAP."
actor: "Site"
uris: "Reported activities"
activity_pubs:
action_on_several:
success: "Several comments have changed moderation state. You can find them using the filters on the Comments section."

View file

@ -119,6 +119,13 @@ es:
confirm_report: "¿Enviar el reporte a la instancia remota? Esta acción también bloqueará la cuenta."
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}."
activity_pub:
actor_flagged_mailer:
notify_moderators:
subject: "Un sitio ha sido reportado"
content: "El sitio con id %{site_id} ha sido reportado. Por favor revisa el reporte a la brevedad."
actor: "Sitio"
uris: "Actividades reportadas"
activity_pubs:
action_on_several:
success: "Se ha modificado el estado de moderación de varios comentarios. Podés encontrarlos usando los filtros en la sección Comentarios."

View file

@ -0,0 +1,8 @@
# frozen_string_literal: true
# Agrega el campo moderator para saber quiénes son moderadores
class AddModeratorToUsuaries < ActiveRecord::Migration[6.1]
def change
add_column :usuaries, :moderator, :boolean, default: false
end
end

View file

@ -1497,7 +1497,8 @@ CREATE TABLE public.usuaries (
privacy_policy_accepted_at timestamp without time zone,
terms_of_service_accepted_at timestamp without time zone,
code_of_conduct_accepted_at timestamp without time zone,
available_for_feedback_accepted_at timestamp without time zone
available_for_feedback_accepted_at timestamp without time zone,
moderator boolean DEFAULT false
);
@ -2734,6 +2735,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20240318183846'),
('20240319124212'),
('20240319144735'),
('20240614191548');
('20240614191548'),
('20241113183226');