diff options
author | Thibaut Girka <thib@sitedethib.com> | 2018-08-26 13:52:12 +0200 |
---|---|---|
committer | Thibaut Girka <thib@sitedethib.com> | 2018-08-26 14:23:24 +0200 |
commit | 36393e1d2b1ce82916bd43ca1068e34cea6f6e39 (patch) | |
tree | a18d7f5e7753ff40355d2a6d4ab9fb765ad4c263 /app/lib/activitypub | |
parent | 2903f8f36b7c41b77de4ad6c8c5b0a6c0b2a7ace (diff) | |
parent | f37fafe30b5f6ff85ebf87fb622293a855877ee1 (diff) |
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts: app/views/layouts/application.html.haml Edited: app/helpers/application_helper.rb app/views/admin/domain_blocks/new.html.haml Conflict wasn't really one, just two changes too close to one another. Edition was to adapt the class names for themes to class names for skins and flavours. Also edited app/views/admin/domain_blocks/new.html.haml to strip the duplicate admin pack inclusion thing.
Diffstat (limited to 'app/lib/activitypub')
-rw-r--r-- | app/lib/activitypub/activity.rb | 4 | ||||
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 16 |
2 files changed, 18 insertions, 2 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index 03476920b..3a39b723e 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -104,7 +104,9 @@ class ActivityPub::Activity def crawl_links(status) return if status.spoiler_text? - LinkCrawlWorker.perform_async(status.id) + + # Spread out crawling randomly to avoid DDoSing the link + LinkCrawlWorker.perform_in(rand(1..59).seconds, status.id) end def distribute_to_followers(status) diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index 79efc95d3..f40e1fa3e 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -48,7 +48,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity account: @account, text: text_from_content || '', language: detected_language, - spoiler_text: @object['summary'] || '', + spoiler_text: text_from_summary || '', created_at: @object['published'], override_timestamps: @options[:override_timestamps], reply: @object['inReplyTo'].present?, @@ -193,6 +193,14 @@ class ActivityPub::Activity::Create < ActivityPub::Activity 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 if @object['name'].present? @object['name'] @@ -206,6 +214,8 @@ class ActivityPub::Activity::Create < ActivityPub::Activity @object['contentMap'].keys.first elsif name_language_map? @object['nameMap'].keys.first + elsif summary_language_map? + @object['summaryMap'].keys.first elsif supported_object_type? LanguageDetector.instance.detect(text_from_content, @account) end @@ -223,6 +233,10 @@ class ActivityPub::Activity::Create < ActivityPub::Activity end end + def summary_language_map? + @object['summaryMap'].is_a?(Hash) && !@object['summaryMap'].empty? + end + def content_language_map? @object['contentMap'].is_a?(Hash) && !@object['contentMap'].empty? end |