diff options
author | Darius Kazemi <darius.kazemi@gmail.com> | 2019-04-30 15:29:28 -0700 |
---|---|---|
committer | Fire Demon <firedemon@creature.cafe> | 2020-08-30 05:45:15 -0500 |
commit | 6378feffa8935238bdb5f1f1c01fcb102440fe30 (patch) | |
tree | b1eea210ace7eb72a00ab4604c3ec10c5ae4db4b /app/lib/activitypub | |
parent | 4eb49257fc618219709b357fb68f4d6156cab249 (diff) |
[Feature, Federation, Port: hometown@b3e6597] Support locally cached inline images [+ Monsterfork additions]
Changes added by Monsterfork: - Do not limit to only Articles - Reuse existing media; retroactively using more-detailed descriptions - Also scrub carrige returns between tags - Handle download failures - Attach to statuses and keep track of inlined media - Handle local edits Co-authored-by: Fire Demon <firedemon@creature.cafe>
Diffstat (limited to 'app/lib/activitypub')
-rw-r--r-- | app/lib/activitypub/activity.rb | 4 | ||||
-rw-r--r-- | app/lib/activitypub/activity/create.rb | 6 |
2 files changed, 7 insertions, 3 deletions
diff --git a/app/lib/activitypub/activity.rb b/app/lib/activitypub/activity.rb index cff6b569a..9b58fabed 100644 --- a/app/lib/activitypub/activity.rb +++ b/app/lib/activitypub/activity.rb @@ -4,8 +4,8 @@ class ActivityPub::Activity include JsonLdHelper include Redisable - SUPPORTED_TYPES = %w(Note Question).freeze - CONVERTED_TYPES = %w(Image Audio Video Article Page Event).freeze + SUPPORTED_TYPES = %w(Note Question Article).freeze + CONVERTED_TYPES = %w(Image Audio Video Page Event).freeze def initialize(json, account, **options) @json = json diff --git a/app/lib/activitypub/activity/create.rb b/app/lib/activitypub/activity/create.rb index fbb4624e3..10a0a9498 100644 --- a/app/lib/activitypub/activity/create.rb +++ b/app/lib/activitypub/activity/create.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true class ActivityPub::Activity::Create < ActivityPub::Activity + include ImgProxyHelper + def perform dereference_object! @@ -94,6 +96,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity ApplicationRecord.transaction do @status = Status.create!(@params) + process_inline_images! attach_tags(@status) end @@ -138,6 +141,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity text: text_from_content || '', language: detected_language, spoiler_text: converted_object_type? ? '' : (text_from_summary || ''), + title: text_from_title, sensitive: @object['sensitive'] || false, visibility: visibility_from_audience, media_attachment_ids: process_attachments.take(4).map(&:id), @@ -433,7 +437,7 @@ class ActivityPub::Activity::Create < ActivityPub::Activity return Formatter.instance.linkify([[text_from_name, text_from_summary.presence].compact.join("\n\n"), object_url || @object['id']].join(' ')) if converted_object_type? if @object['content'].present? - @object['content'] + @object['type'] == 'Article' ? Formatter.instance.format_article(@object['content']) : @object['content'] elsif content_language_map? @object['contentMap'].values.first end |