mirror of
https://0xacab.org/sutty/sutty
synced 2024-11-23 04:46:21 +00:00
fix: recibir actividades correctamente
This commit is contained in:
parent
aeb8f88493
commit
6eaf00c7ad
1 changed files with 6 additions and 2 deletions
|
@ -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!
|
||||
|
|
Loading…
Reference in a new issue