Support ActivityStreams’ summaryMap. (#8422)
In the same way as contentMap and nameMap.lolsob-rspec
parent
4b27569841
commit
777e09500e
|
@ -48,7 +48,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
account: @account,
|
account: @account,
|
||||||
text: text_from_content || '',
|
text: text_from_content || '',
|
||||||
language: detected_language,
|
language: detected_language,
|
||||||
spoiler_text: @object['summary'] || '',
|
spoiler_text: text_from_summary || '',
|
||||||
created_at: @object['published'],
|
created_at: @object['published'],
|
||||||
override_timestamps: @options[:override_timestamps],
|
override_timestamps: @options[:override_timestamps],
|
||||||
reply: @object['inReplyTo'].present?,
|
reply: @object['inReplyTo'].present?,
|
||||||
|
@ -193,6 +193,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def text_from_summary
|
||||||
|
if @object['summary'].present?
|
||||||
|
@object['summary']
|
||||||
|
elsif summary_language_map?
|
||||||
|
@object['summaryMap'].values.first
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def text_from_name
|
def text_from_name
|
||||||
if @object['name'].present?
|
if @object['name'].present?
|
||||||
@object['name']
|
@object['name']
|
||||||
|
@ -206,6 +214,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
@object['contentMap'].keys.first
|
@object['contentMap'].keys.first
|
||||||
elsif name_language_map?
|
elsif name_language_map?
|
||||||
@object['nameMap'].keys.first
|
@object['nameMap'].keys.first
|
||||||
|
elsif summary_language_map?
|
||||||
|
@object['summaryMap'].keys.first
|
||||||
elsif supported_object_type?
|
elsif supported_object_type?
|
||||||
LanguageDetector.instance.detect(text_from_content, @account)
|
LanguageDetector.instance.detect(text_from_content, @account)
|
||||||
end
|
end
|
||||||
|
@ -223,6 +233,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def summary_language_map?
|
||||||
|
@object['summaryMap'].is_a?(Hash) && !@object['summaryMap'].empty?
|
||||||
|
end
|
||||||
|
|
||||||
def content_language_map?
|
def content_language_map?
|
||||||
@object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty?
|
@object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty?
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue