diff --git a/app/models/activity_pub.rb b/app/models/activity_pub.rb index c0474b89..c15998ea 100644 --- a/app/models/activity_pub.rb +++ b/app/models/activity_pub.rb @@ -29,5 +29,16 @@ class ActivityPub < ApplicationRecord state :reported # Le actore eliminó el objeto state :deleted + + # Recibir una acción de eliminación, eliminar el contenido de la + # base de datos. Esto elimina el contenido para todos los sitios + # porque estamos respetando lo que pidió le actore. + event :delete do + transitions to: :deleted + + after do + object.update(object: {}) + end + end end end diff --git a/app/models/activity_pub/activity/delete.rb b/app/models/activity_pub/activity/delete.rb index f3684a0f..1730d49d 100644 --- a/app/models/activity_pub/activity/delete.rb +++ b/app/models/activity_pub/activity/delete.rb @@ -1,3 +1,9 @@ # frozen_string_literal: true -class ActivityPub::Activity::Delete < ActivityPub::Activity; end +class ActivityPub::Activity::Delete < ActivityPub::Activity + # Si estamos eliminando el objeto, tenemos que vaciar su contenido y + # cambiar el estado a borrado + def update_activity_pub_state! + activity_pub.deleted! + end +end