From 00270b7829266120fa2e3beaa87ffde118cae38a Mon Sep 17 00:00:00 2001 From: f Date: Fri, 15 Mar 2024 18:05:05 -0300 Subject: [PATCH] fix: no mostrar likes #15596 --- app/models/activity_pub.rb | 16 ++++++++++++++-- app/processors/activity_pub_processor.rb | 9 ++++++++- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/app/models/activity_pub.rb b/app/models/activity_pub.rb index 73006d1d..3671000c 100644 --- a/app/models/activity_pub.rb +++ b/app/models/activity_pub.rb @@ -6,6 +6,12 @@ # una actividad, puede estar destinada a varies actores dentro de Sutty, # con lo que generamos una cola para cada une. # +# +# @todo Ya que une actore puede hacer varias actividades sobre el mismo +# objeto, lo correcto sería que la actividad a moderar sea una sola en +# lugar de una lista acumulativa. Es decir cada ActivityPub representa +# el estado del conjunto (Actor, Object, Activity) +# # @see {https://www.w3.org/TR/activitypub/#client-to-server-interactions} class ActivityPub < ApplicationRecord IGNORED_EVENTS = %i[pause remove].freeze @@ -105,10 +111,16 @@ class ActivityPub < ApplicationRecord # disponible, que según el scope por defecto, va a ser la primera de # la lista. def reject_remotely! - raise unless site.social_inbox.inbox.reject(id: activities.first.uri).ok? + fail! unless site.social_inbox.inbox.reject(id: activities.first.uri).ok? end def allow_remotely! - raise unless site.social_inbox.inbox.accept(id: activities.first.uri).ok? + with_failure_handling(activity: activities.first.uri) do + fail! unless site.social_inbox.inbox.accept(id: activities.first.uri).ok? + end + end + + def fail_message + activities.first&.uri || 'Activity missing' end end diff --git a/app/processors/activity_pub_processor.rb b/app/processors/activity_pub_processor.rb index 52cdb6d3..501b73a5 100644 --- a/app/processors/activity_pub_processor.rb +++ b/app/processors/activity_pub_processor.rb @@ -6,7 +6,14 @@ class ActivityPubProcessor < Rubanok::Processor # # Por ahora solo queremos moderar comentarios. prepare do - raw.where(object_type: %w[ActivityPub::Object::Note ActivityPub::Object::Article]).order(updated_at: :desc) + raw + .joins(:activities) + .where( + activity_pub_activities: { + type: %w[ActivityPub::Activity::Create ActivityPub::Activity::Update] + }, + object_type: %w[ActivityPub::Object::Note ActivityPub::Object::Article] + ).order(updated_at: :desc) end map :activity_pub_state, activate_always: true do |activity_pub_state: 'paused'|