From ccd3df2038b893b0ead29682df691dbb81862dfa Mon Sep 17 00:00:00 2001 From: f Date: Mon, 4 Mar 2024 16:46:43 -0300 Subject: [PATCH] feat: aprobar o rechazar actividades --- app/models/activity_pub.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/models/activity_pub.rb b/app/models/activity_pub.rb index 51ee0d71..838eea80 100644 --- a/app/models/activity_pub.rb +++ b/app/models/activity_pub.rb @@ -64,14 +64,26 @@ class ActivityPub < ApplicationRecord transitions from: %i[approved rejected], to: :paused end - # La actividad se aprueba + # La actividad se aprueba, informándole a la Social Inbox que está + # aprobada. También recibimos la aprobación via + # webhook a modo de confirmación. event :approve do transitions from: %i[paused rejected], to: :approved + + before do + raise AASM::InvalidTransition unless + site.social_inbox.inbox.accept(id: object.uri).ok? + end end # La actividad fue rechazada event :reject do transitions from: %i[paused approved], to: :rejected + + before do + raise AASM::InvalidTransition unless + site.social_inbox.inbox.reject(id: object.uri).ok? + end end # Solo podemos reportarla luego de rechazarla