From 6378feffa8935238bdb5f1f1c01fcb102440fe30 Mon Sep 17 00:00:00 2001 From: Darius Kazemi Date: Tue, 30 Apr 2019 15:29:28 -0700 Subject: [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 --- app/services/update_status_service.rb | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'app/services/update_status_service.rb') diff --git a/app/services/update_status_service.rb b/app/services/update_status_service.rb index 795e43d01..f59f26a25 100644 --- a/app/services/update_status_service.rb +++ b/app/services/update_status_service.rb @@ -2,6 +2,7 @@ class UpdateStatusService < BaseService include Redisable + include ImgProxyHelper ALLOWED_ATTRIBUTES = %i( spoiler_text @@ -42,11 +43,19 @@ class UpdateStatusService < BaseService @deleted_tag_ids = @status.tag_ids - @tags.pluck(:id) @deleted_tag_names = @status.tags.pluck(:name) - @tags.pluck(:name) @deleted_attachment_ids = @status.media_attachment_ids - (@params[:media_attachment_ids] || @params[:media_attachments]&.pluck(:id) || []) - @new_mention_ids = @mentions.pluck(:id) - @status.mention_ids + + @new_mention_ids = @mentions.pluck(:id) - @status.mention_ids ApplicationRecord.transaction do @status.update!(@params) - ProcessCommandTagsService.new.call(@account, @status) if @account.local? + + if @account.local? + ProcessCommandTagsService.new.call(@account, @status) + else + process_inline_images! + @status.save! + end + detach_deleted_tags attach_updated_tags end @@ -64,6 +73,7 @@ class UpdateStatusService < BaseService private def prune_attachments + @new_inline_ids = @status.inlined_attachments.pluck(:media_attachment_id) RemoveMediaAttachmentsWorker.perform_async(@deleted_attachment_ids) if @deleted_attachment_ids.present? end -- cgit