From 9a479a157b6d865cf4233c9737bf26d750934e99 Mon Sep 17 00:00:00 2001 From: f Date: Tue, 20 Feb 2024 17:18:15 -0300 Subject: [PATCH] feat: volver a pausar un objeto aprobado cuando se lo actualiza --- app/models/activity_pub.rb | 6 ++++++ app/models/activity_pub/activity/update.rb | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/app/models/activity_pub.rb b/app/models/activity_pub.rb index c15998ea..2a127433 100644 --- a/app/models/activity_pub.rb +++ b/app/models/activity_pub.rb @@ -40,5 +40,11 @@ class ActivityPub < ApplicationRecord object.update(object: {}) end end + + # Si un objeto previamente aprobado fue actualizado, volvemos a + # pausarlo. + event :pause do + transitions from: :approved, to: :paused + end end end diff --git a/app/models/activity_pub/activity/update.rb b/app/models/activity_pub/activity/update.rb index 34703938..e9203ba5 100644 --- a/app/models/activity_pub/activity/update.rb +++ b/app/models/activity_pub/activity/update.rb @@ -4,6 +4,6 @@ class ActivityPub::Activity::Update < ActivityPub::Activity # Si estamos actualizando el objeto, tenemos que devolverlo a estado # de moderaciĆ³n def update_activity_pub_state! - activity_pub.paused! + activity_pub.pause! if activity_pub.approved? end end