mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-25 14:16:22 +00:00
feat: moderar actores
This commit is contained in:
parent
eafe8bcdd5
commit
f524724c0f
5 changed files with 86 additions and 1 deletions
|
@ -10,6 +10,7 @@ class ActivityPub
|
||||||
include ActivityPub::Concerns::JsonLdConcern
|
include ActivityPub::Concerns::JsonLdConcern
|
||||||
|
|
||||||
belongs_to :instance
|
belongs_to :instance
|
||||||
|
has_many :actor_moderation
|
||||||
has_many :activity_pubs, as: :object
|
has_many :activity_pubs, as: :object
|
||||||
has_many :activities
|
has_many :activities
|
||||||
end
|
end
|
||||||
|
|
32
app/models/actor_moderation.rb
Normal file
32
app/models/actor_moderation.rb
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Mantiene la relación entre Site y Actor
|
||||||
|
class ActorModeration < ApplicationRecord
|
||||||
|
include AASM
|
||||||
|
|
||||||
|
belongs_to :site
|
||||||
|
belongs_to :actor, class_name: 'ActivityPub::Actor'
|
||||||
|
|
||||||
|
aasm do
|
||||||
|
state :paused, initial: true
|
||||||
|
state :allowed
|
||||||
|
state :blocked
|
||||||
|
state :reported
|
||||||
|
|
||||||
|
event :pause do
|
||||||
|
transitions from: %i[allowed blocked reported], to: :paused
|
||||||
|
end
|
||||||
|
|
||||||
|
event :allowed do
|
||||||
|
transitions from: %i[paused blocked reported], to: :allowed
|
||||||
|
end
|
||||||
|
|
||||||
|
event :blocked do
|
||||||
|
transitions from: %i[paused allowed], to: :blocked
|
||||||
|
end
|
||||||
|
|
||||||
|
event :reported do
|
||||||
|
transitions from: %i[blocked], to: :reported
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -12,6 +12,7 @@ class Site
|
||||||
|
|
||||||
has_many :activity_pubs
|
has_many :activity_pubs
|
||||||
has_many :instance_moderations
|
has_many :instance_moderations
|
||||||
|
has_many :actor_moderations
|
||||||
has_many :fediblock_states
|
has_many :fediblock_states
|
||||||
has_many :instances, through: :instance_moderations
|
has_many :instances, through: :instance_moderations
|
||||||
|
|
||||||
|
|
14
db/migrate/20240228202830_create_actor_moderations.rb
Normal file
14
db/migrate/20240228202830_create_actor_moderations.rb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# Relación entre Actor y Site
|
||||||
|
class CreateActorModerations < ActiveRecord::Migration[6.1]
|
||||||
|
def change
|
||||||
|
create_table :actor_moderations, id: :uuid do |t|
|
||||||
|
t.timestamps
|
||||||
|
|
||||||
|
t.belongs_to :site
|
||||||
|
t.uuid :actor_id, index: true
|
||||||
|
t.string :aasm_state, null: false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -562,6 +562,20 @@ CREATE TABLE public.activity_pubs (
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: actor_moderations; Type: TABLE; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE TABLE public.actor_moderations (
|
||||||
|
id uuid DEFAULT gen_random_uuid() NOT NULL,
|
||||||
|
created_at timestamp(6) without time zone NOT NULL,
|
||||||
|
updated_at timestamp(6) without time zone NOT NULL,
|
||||||
|
site_id bigint,
|
||||||
|
actor_id uuid,
|
||||||
|
aasm_state character varying NOT NULL
|
||||||
|
);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
|
-- Name: ar_internal_metadata; Type: TABLE; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -1756,6 +1770,14 @@ ALTER TABLE ONLY public.activity_pubs
|
||||||
ADD CONSTRAINT activity_pubs_pkey PRIMARY KEY (id);
|
ADD CONSTRAINT activity_pubs_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: actor_moderations actor_moderations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
ALTER TABLE ONLY public.actor_moderations
|
||||||
|
ADD CONSTRAINT actor_moderations_pkey PRIMARY KEY (id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: blazer_audits blazer_audits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
-- Name: blazer_audits blazer_audits_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2107,6 +2129,20 @@ CREATE INDEX index_activity_pub_instances_on_hostname ON public.activity_pub_ins
|
||||||
CREATE UNIQUE INDEX index_activity_pubs_on_site_id_and_object_id_and_object_type ON public.activity_pubs USING btree (site_id, object_id, object_type);
|
CREATE UNIQUE INDEX index_activity_pubs_on_site_id_and_object_id_and_object_type ON public.activity_pubs USING btree (site_id, object_id, object_type);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_actor_moderations_on_actor_id; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_actor_moderations_on_actor_id ON public.actor_moderations USING btree (actor_id);
|
||||||
|
|
||||||
|
|
||||||
|
--
|
||||||
|
-- Name: index_actor_moderations_on_site_id; Type: INDEX; Schema: public; Owner: -
|
||||||
|
--
|
||||||
|
|
||||||
|
CREATE INDEX index_actor_moderations_on_site_id ON public.actor_moderations USING btree (site_id);
|
||||||
|
|
||||||
|
|
||||||
--
|
--
|
||||||
-- Name: index_blazer_audits_on_query_id; Type: INDEX; Schema: public; Owner: -
|
-- Name: index_blazer_audits_on_query_id; Type: INDEX; Schema: public; Owner: -
|
||||||
--
|
--
|
||||||
|
@ -2616,6 +2652,7 @@ INSERT INTO "schema_migrations" (version) VALUES
|
||||||
('20240226134335'),
|
('20240226134335'),
|
||||||
('20240227134845'),
|
('20240227134845'),
|
||||||
('20240227142019'),
|
('20240227142019'),
|
||||||
('20240228171335');
|
('20240228171335'),
|
||||||
|
('20240228202830');
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue