about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorDarius Kazemi <darius.kazemi@gmail.com>2019-04-30 15:29:28 -0700
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:15 -0500
commit6378feffa8935238bdb5f1f1c01fcb102440fe30 (patch)
treeb1eea210ace7eb72a00ab4604c3ec10c5ae4db4b /app/services
parent4eb49257fc618219709b357fb68f4d6156cab249 (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/services')
-rw-r--r--app/services/post_status_service.rb1
-rw-r--r--app/services/update_status_service.rb14
2 files changed, 13 insertions, 2 deletions
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
index eb60c1022..aef630f71 100644
--- a/app/services/post_status_service.rb
+++ b/app/services/post_status_service.rb
@@ -2,6 +2,7 @@
 
 class PostStatusService < BaseService
   include Redisable
+  include ImgProxyHelper
 
   MIN_SCHEDULE_OFFSET = 5.minutes.freeze
 
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