about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2019-08-22 04:17:12 +0200
committermultiple creatures <dev@multiple-creature.party>2020-02-21 01:17:02 -0600
commit4692c6033fe23c375651e55837550cfb33e49895 (patch)
tree7218e8ea7aca65ecd1916abcec36712f5a822c07 /app/services
parent808ec5f4bafc5916e29733df8d7854f5aa493c90 (diff)
port tootsuite#11638 to monsterfork: Fix remote and staff-removed statuses leaving media behind for a day
The reason for unattaching media instead of removing it is to support
delete & redraft functionality, but remote or staff-removed statuses
will never be redrafted, so the media should be deleted immediately
Diffstat (limited to 'app/services')
-rw-r--r--app/services/batched_remove_status_service.rb2
-rw-r--r--app/services/remove_status_service.rb12
2 files changed, 13 insertions, 1 deletions
diff --git a/app/services/batched_remove_status_service.rb b/app/services/batched_remove_status_service.rb
index 09d094c15..7318831e7 100644
--- a/app/services/batched_remove_status_service.rb
+++ b/app/services/batched_remove_status_service.rb
@@ -6,7 +6,7 @@ class BatchedRemoveStatusService < BaseService
   # Delete given statuses and reblogs of them
   # Remove statuses from home feeds
   # Push delete events to streaming API for home feeds and public feeds
-  # @param [Status] statuses A preferably batched array of statuses
+  # @param [Enumerable<Status>] statuses A preferably batched array of statuses
   # @param [Hash] options
   # @option [Boolean] :skip_side_effects
   def call(statuses, **options)
diff --git a/app/services/remove_status_service.rb b/app/services/remove_status_service.rb
index 51d200361..42ae9591d 100644
--- a/app/services/remove_status_service.rb
+++ b/app/services/remove_status_service.rb
@@ -6,6 +6,11 @@ class RemoveStatusService < BaseService
 
   MIN_SCHEDULE_OFFSET = 60.seconds.freeze
 
+  # Delete a status
+  # @param   [Status] status
+  # @param   [Hash] options
+  # @option  [Boolean] :redraft
+  # @options [Boolean] :original_removed
   def call(status, **options)
     @payload  = Oj.dump(event: :delete, payload: status.id.to_s)
     @status   = status
@@ -29,6 +34,7 @@ class RemoveStatusService < BaseService
           remove_from_media if status.media_attachments.any?
           remove_from_direct if status.direct_visibility?
           remove_from_spam_check
+          remove_media
 
           @status.destroy!
         else
@@ -162,6 +168,12 @@ class RemoveStatusService < BaseService
     Redis.current.publish("timeline:direct:#{@account.id}", @payload) if @account.local?
   end
 
+  def remove_media
+    return if @options[:redraft]
+
+    @status.media_attachments.destroy_all
+  end
+
   def remove_from_spam_check
     redis.zremrangebyscore("spam_check:#{@status.account_id}", @status.id, @status.id)
   end