From 5bf26a7fb2f7b7fb73efd11f110ea8ec6bb44383 Mon Sep 17 00:00:00 2001 From: f Date: Thu, 14 Mar 2024 12:27:59 -0300 Subject: [PATCH] fix: arreglar las relaciones entre actividades y objetos --- app/jobs/activity_pub/fetch_job.rb | 4 ++++ ...0240314153017_fix_object_type_on_activity_pubs.rb | 12 ++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 db/migrate/20240314153017_fix_object_type_on_activity_pubs.rb diff --git a/app/jobs/activity_pub/fetch_job.rb b/app/jobs/activity_pub/fetch_job.rb index 6a4d163b..d7003c11 100644 --- a/app/jobs/activity_pub/fetch_job.rb +++ b/app/jobs/activity_pub/fetch_job.rb @@ -24,9 +24,13 @@ class ActivityPub return unless response.ok? return if response.miss? && object.content.present? + current_type = object.type content = FastJsonparser.parse(response.body) object.update(content: content, type: ActivityPub::Object.type_from(content).name) + + # Arreglar las relaciones con actividades también + ActivityPub.where(object_id: object.id).update_all(object_type: object.type) unless current_type == object.type end end end diff --git a/db/migrate/20240314153017_fix_object_type_on_activity_pubs.rb b/db/migrate/20240314153017_fix_object_type_on_activity_pubs.rb new file mode 100644 index 00000000..81149ad4 --- /dev/null +++ b/db/migrate/20240314153017_fix_object_type_on_activity_pubs.rb @@ -0,0 +1,12 @@ +# frozen_string_literal: true + +# Arregla la relación rota entre ActivityPub y Objects +class FixObjectTypeOnActivityPubs < ActiveRecord::Migration[6.1] + def up + ActivityPub::Object.where.not(type: 'ActivityPub::Object::Generic').find_each do |object| + ActivityPub.where(object_id: object.id).update_all(type: object.type, updated_at: Time.now) + end + end + + def down; end +end