Skip to content

Commit

Permalink
Change post-processing to be deferred only for large media types (mas…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored Nov 1, 2022
1 parent c68e6b5 commit 15bae3e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/media_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
class Api::V2::MediaController < Api::V1::MediaController
def create
@media_attachment = current_account.media_attachments.create!({ delay_processing: true }.merge(media_attachment_params))
render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: 202
render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: @media_attachment.not_processed? ? 202 : 200
rescue Paperclip::Errors::NotIdentifiedByImageMagickError
render json: file_type_error, status: 422
rescue Paperclip::Error
Expand Down
4 changes: 2 additions & 2 deletions app/models/media_attachment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ def focus
attr_writer :delay_processing

def delay_processing?
@delay_processing
@delay_processing && larger_media_format?
end

def delay_processing_for_attachment?(attachment_name)
@delay_processing && attachment_name == :file
delay_processing? && attachment_name == :file
end

after_commit :enqueue_processing, on: :create
Expand Down

0 comments on commit 15bae3e

Please sign in to comment.