Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add _:inReplyToAtomUri to ActivityPub #4702

Merged
merged 1 commit into from Aug 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion app/helpers/jsonld_helper.rb
Expand Up @@ -10,7 +10,7 @@ def first_of_value(value)
end

def value_or_id(value)
value.is_a?(String) ? value : value['id']
value.is_a?(String) || value.nil? ? value : value['id']
end

def supported_context?(json)
Expand Down
17 changes: 14 additions & 3 deletions app/lib/activitypub/activity/create.rb
Expand Up @@ -91,7 +91,7 @@ def process_attachments(status)

def resolve_thread(status)
return unless status.reply? && status.thread.nil?
ThreadResolveWorker.perform_async(status.id, @object['inReplyTo'])
ThreadResolveWorker.perform_async(status.id, in_reply_to_uri)
end

def conversation_from_uri(uri)
Expand All @@ -118,8 +118,19 @@ def audience_includes?(account)
end

def replied_to_status
return if @object['inReplyTo'].blank?
@replied_to_status ||= status_from_uri(@object['inReplyTo'])
return @replied_to_status if defined?(@replied_to_status)

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

def text_from_content
Expand Down
6 changes: 5 additions & 1 deletion app/serializers/activitypub/activity_serializer.rb
Expand Up @@ -10,7 +10,7 @@ def id
end

def type
object.reblog? ? 'Announce' : 'Create'
announce? ? 'Announce' : 'Create'
end

def actor
Expand All @@ -24,4 +24,8 @@ def to
def cc
ActivityPub::TagManager.instance.cc(object)
end

def announce?
object.reblog?
end
end
7 changes: 7 additions & 0 deletions app/serializers/activitypub/note_serializer.rb
Expand Up @@ -9,6 +9,7 @@ class ActivityPub::NoteSerializer < ActiveModel::Serializer
has_many :virtual_tags, key: :tag

attribute :atom_uri, key: '_:atomUri', if: :local?
attribute :in_reply_to_atom_uri, key: '_:inReplyToAtomUri'

def id
ActivityPub::TagManager.instance.uri_for(object)
Expand Down Expand Up @@ -64,6 +65,12 @@ def atom_uri
::TagManager.instance.uri_for(object)
end

def in_reply_to_atom_uri
return unless object.reply?

::TagManager.instance.uri_for(object.thread)
end

def local?
object.account.local?
end
Expand Down