From 6eaf00c7ad1597a2bac9b22e1719f10ad8e70b7b Mon Sep 17 00:00:00 2001 From: f Date: Wed, 28 Feb 2024 17:52:24 -0300 Subject: [PATCH] fix: recibir actividades correctamente --- .../api/v1/webhooks/social_inbox_controller.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/controllers/api/v1/webhooks/social_inbox_controller.rb b/app/controllers/api/v1/webhooks/social_inbox_controller.rb index f52525f1..34ef1d6c 100644 --- a/app/controllers/api/v1/webhooks/social_inbox_controller.rb +++ b/app/controllers/api/v1/webhooks/social_inbox_controller.rb @@ -5,6 +5,9 @@ module Api module Webhooks # Recibe webhooks de la Social Inbox # + # @todo Mover todo a un Job que obtenga el objeto remoto antes de + # instanciar el objeto localmente en lugar de arreglarlo después y + # poder responder lo más rápido posible el webhook. # @see {https://www.w3.org/TR/activitypub/} class SocialInboxController < BaseController include Api::V1::Webhooks::Concerns::WebhookConcern @@ -28,6 +31,7 @@ module Api instance.present? object.present? activity_pub.present? + activity.update_activity_pub_state! end rescue ActiveRecord::RecordInvalid => e @@ -125,7 +129,7 @@ module Api # # @return [ActivityPub] def activity_pub - @activity_pub ||= site.activity_pubs.find_or_create_by!(site: site, object: object) + @activity_pub ||= site.activity_pubs.find_or_create_by!(site: site, instance: instance, object: object) end # Crea la actividad y la vincula con el estado @@ -135,7 +139,7 @@ module Api @activity ||= ActivityPub::Activity .type_from(original_activity) - .find_or_initialize_by(uri: original_activity[:id], activity_pub: activity_pub).tap do |a| + .find_or_initialize_by(uri: original_activity[:id], activity_pub: activity_pub, actor: actor).tap do |a| a.content = original_activity.dup a.content[:object] = object.uri a.save!