def status_params
{
uri: @object['id'],
- url: @object['url'] || @object['id'],
+ url: object_url || @object['id'],
account: @account,
text: text_from_content || '',
language: language_from_content,
@object['contentMap'].keys.first
end
+ def object_url
+ return if @object['url'].blank?
+
+ value = first_of_value(@object['url'])
+
+ return value if value.is_a?(String)
+
+ value['href']
+ end
+
def language_map?
@object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty?
end
include RoutingHelper
attributes :id, :type, :following, :followers,
- :inbox, :outbox, :shared_inbox,
+ :inbox, :outbox,
:preferred_username, :name, :summary,
:url, :manually_approves_followers
end
end
+ class EndpointsSerializer < ActiveModel::Serializer
+ include RoutingHelper
+
+ attributes :shared_inbox
+
+ def shared_inbox
+ inbox_url
+ end
+ end
+
+ has_one :endpoints, serializer: EndpointsSerializer
+
has_one :icon, serializer: ImageSerializer, if: :avatar_exists?
has_one :image, serializer: ImageSerializer, if: :header_exists?
account_outbox_url(object)
end
- def shared_inbox
- inbox_url
+ def endpoints
+ object
end
def preferred_username
# Should be called with confirmed valid JSON
# and WebFinger-resolved username and domain
def call(username, domain, json)
- return unless json['inbox'].present?
+ return if json['inbox'].blank?
@json = json
@uri = @json['id']
@account.protocol = :activitypub
@account.inbox_url = @json['inbox'] || ''
@account.outbox_url = @json['outbox'] || ''
- @account.shared_inbox_url = @json['sharedInbox'] || ''
+ @account.shared_inbox_url = (@json['endpoints'].is_a?(Hash) ? @json['endpoints']['sharedInbox'] : @json['sharedInbox']) || ''
@account.followers_url = @json['followers'] || ''
- @account.url = @json['url'] || @uri
+ @account.url = url || @uri
@account.display_name = @json['name'] || ''
@account.note = @json['summary'] || ''
@account.avatar_remote_url = image_url('icon')
value = first_of_value(@json[key])
return if value.nil?
- return @json[key]['url'] if @json[key].is_a?(Hash)
+ return value['url'] if value.is_a?(Hash)
image = fetch_resource(value)
image['url'] if image
key['publicKeyPem'] if key
end
+ def url
+ return if @json['url'].blank?
+
+ value = first_of_value(@json['url'])
+
+ return value if value.is_a?(String)
+
+ value['href']
+ end
+
def auto_suspend?
domain_block && domain_block.suspend?
end