mirror of
https://0xacab.org/sutty/sutty
synced 2024-12-01 09:56:22 +00:00
Merge branch 'issue-15109-1' of https://0xacab.org/sutty/sutty into production.panel.sutty.nl
This commit is contained in:
commit
a1d218fb03
2 changed files with 19 additions and 3 deletions
|
@ -29,15 +29,16 @@ class ActivityPub
|
||||||
current_type = object.type
|
current_type = object.type
|
||||||
content = FastJsonparser.parse(response.body)
|
content = FastJsonparser.parse(response.body)
|
||||||
|
|
||||||
object.update(content: content, type: ActivityPub::Object.type_from(content).name)
|
object.update!(content: content, type: ActivityPub::Object.type_from(content).name)
|
||||||
|
|
||||||
return if current_type == object.type
|
return if current_type == object.type
|
||||||
|
|
||||||
object = ::ActivityPub::Object.find(object_id)
|
object = ::ActivityPub::Object.find(object_id)
|
||||||
object.actor&.save if object.actor_type?
|
# Actualiza la mención
|
||||||
|
object.actor&.save! if object.actor_type?
|
||||||
|
|
||||||
# Arreglar las relaciones con actividades también
|
# Arreglar las relaciones con actividades también
|
||||||
ActivityPub.where(object_id: object.id).update_all(object_type: object.type)
|
ActivityPub.where(object_id: object.id).update_all(object_type: object.type, updated_at: Time.now)
|
||||||
rescue FastJsonparser::ParseError => e
|
rescue FastJsonparser::ParseError => e
|
||||||
ExceptionNotifier.notify_exception(e, data: { site: site.name, body: response.body })
|
ExceptionNotifier.notify_exception(e, data: { site: site.name, body: response.body })
|
||||||
end
|
end
|
||||||
|
|
15
db/migrate/20240318183846_fix_duplicate_objects.rb
Normal file
15
db/migrate/20240318183846_fix_duplicate_objects.rb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
# De alguna forma se guardaron objetos duplicados!
|
||||||
|
class FixDuplicateObjects < ActiveRecord::Migration[6.1]
|
||||||
|
def up
|
||||||
|
ActivityPub::Object.group(:uri).count.select { |_, v| v > 1 }.keys.each do |uri|
|
||||||
|
objects = ActivityPub::Object.where(uri: uri)
|
||||||
|
deleted_ids = objects[1..].map(&:delete).map(&:id)
|
||||||
|
|
||||||
|
ActivityPub.where(object_id: deleted_ids).update_all(object_id: object.first.id, updated_at: Time.now)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def down; end
|
||||||
|
end
|
Loading…
Reference in a new issue