Add _:inReplyToAtomUri to ActivityPub (#4702)
This commit is contained in:
parent
0397c58b61
commit
0d5d11eeff
|
@ -10,7 +10,7 @@ module JsonLdHelper
|
||||||
end
|
end
|
||||||
|
|
||||||
def value_or_id(value)
|
def value_or_id(value)
|
||||||
value.is_a?(String) ? value : value['id']
|
value.is_a?(String) || value.nil? ? value : value['id']
|
||||||
end
|
end
|
||||||
|
|
||||||
def supported_context?(json)
|
def supported_context?(json)
|
||||||
|
|
|
@ -91,7 +91,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
|
|
||||||
def resolve_thread(status)
|
def resolve_thread(status)
|
||||||
return unless status.reply? && status.thread.nil?
|
return unless status.reply? && status.thread.nil?
|
||||||
ThreadResolveWorker.perform_async(status.id, @object['inReplyTo'])
|
ThreadResolveWorker.perform_async(status.id, in_reply_to_uri)
|
||||||
end
|
end
|
||||||
|
|
||||||
def conversation_from_uri(uri)
|
def conversation_from_uri(uri)
|
||||||
|
@ -118,8 +118,19 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def replied_to_status
|
def replied_to_status
|
||||||
return if @object['inReplyTo'].blank?
|
return @replied_to_status if defined?(@replied_to_status)
|
||||||
@replied_to_status ||= status_from_uri(@object['inReplyTo'])
|
|
||||||
|
if in_reply_to_uri.blank?
|
||||||
|
@replied_to_status = nil
|
||||||
|
else
|
||||||
|
@replied_to_status = status_from_uri(in_reply_to_uri)
|
||||||
|
@replied_to_status ||= status_from_uri(@object['_:inReplyToAtomUri']) if @object['_:inReplyToAtomUri'].present?
|
||||||
|
@replied_to_status
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def in_reply_to_uri
|
||||||
|
value_or_id(@object['inReplyTo'])
|
||||||
end
|
end
|
||||||
|
|
||||||
def text_from_content
|
def text_from_content
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||||
end
|
end
|
||||||
|
|
||||||
def type
|
def type
|
||||||
object.reblog? ? 'Announce' : 'Create'
|
announce? ? 'Announce' : 'Create'
|
||||||
end
|
end
|
||||||
|
|
||||||
def actor
|
def actor
|
||||||
|
@ -24,4 +24,8 @@ class ActivityPub::ActivitySerializer < ActiveModel::Serializer
|
||||||
def cc
|
def cc
|
||||||
ActivityPub::TagManager.instance.cc(object)
|
ActivityPub::TagManager.instance.cc(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def announce?
|
||||||
|
object.reblog?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||||
has_many :virtual_tags, key: :tag
|
has_many :virtual_tags, key: :tag
|
||||||
|
|
||||||
attribute :atom_uri, key: '_:atomUri', if: :local?
|
attribute :atom_uri, key: '_:atomUri', if: :local?
|
||||||
|
attribute :in_reply_to_atom_uri, key: '_:inReplyToAtomUri'
|
||||||
|
|
||||||
def id
|
def id
|
||||||
ActivityPub::TagManager.instance.uri_for(object)
|
ActivityPub::TagManager.instance.uri_for(object)
|
||||||
|
@ -64,6 +65,12 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
|
||||||
::TagManager.instance.uri_for(object)
|
::TagManager.instance.uri_for(object)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def in_reply_to_atom_uri
|
||||||
|
return unless object.reply?
|
||||||
|
|
||||||
|
::TagManager.instance.uri_for(object.thread)
|
||||||
|
end
|
||||||
|
|
||||||
def local?
|
def local?
|
||||||
object.account.local?
|
object.account.local?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue