Allow ActivityPub Note's tag and attachment to be single objects (#5534)
parent
75776cf237
commit
2c06b21883
|
@ -9,6 +9,10 @@ module JsonLdHelper
|
||||||
value.is_a?(Array) ? value.first : value
|
value.is_a?(Array) ? value.first : value
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def as_array(value)
|
||||||
|
value.is_a?(Array) ? value : [value]
|
||||||
|
end
|
||||||
|
|
||||||
def value_or_id(value)
|
def value_or_id(value)
|
||||||
value.is_a?(String) || value.nil? ? value : value['id']
|
value.is_a?(String) || value.nil? ? value : value['id']
|
||||||
end
|
end
|
||||||
|
|
|
@ -53,9 +53,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_tags(status)
|
def process_tags(status)
|
||||||
return unless @object['tag'].is_a?(Array)
|
return if @object['tag'].nil?
|
||||||
|
|
||||||
@object['tag'].each do |tag|
|
as_array(@object['tag']).each do |tag|
|
||||||
case tag['type']
|
case tag['type']
|
||||||
when 'Hashtag'
|
when 'Hashtag'
|
||||||
process_hashtag tag, status
|
process_hashtag tag, status
|
||||||
|
@ -103,9 +103,9 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
|
|
||||||
def process_attachments(status)
|
def process_attachments(status)
|
||||||
return unless @object['attachment'].is_a?(Array)
|
return if @object['attachment'].nil?
|
||||||
|
|
||||||
@object['attachment'].each do |attachment|
|
as_array(@object['attachment']).each do |attachment|
|
||||||
next if unsupported_media_type?(attachment['mediaType']) || attachment['url'].blank?
|
next if unsupported_media_type?(attachment['mediaType']) || attachment['url'].blank?
|
||||||
|
|
||||||
href = Addressable::URI.parse(attachment['url']).normalize.to_s
|
href = Addressable::URI.parse(attachment['url']).normalize.to_s
|
||||||
|
|
Loading…
Reference in New Issue