about summary refs log tree commit diff
path: root/app/services/remove_media_attachments_service.rb
blob: de3cd9afbfe81a41a587d10e8160c1c7348102d5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
# frozen_string_literal: true

class RemoveMediaAttachmentsService < BaseService
  # Remove a list of media attachments by their IDs
  # @param [Enumerable] attachment_ids
  def call(attachment_ids)
    media_attachments = MediaAttachment.where(id: attachment_ids)
    media_attachments.map(&:id).each { |id| Rails.cache.delete_matched("statuses/#{id}-*") }
    media_attachments.destroy_all
  end
end