Compare commits

...

2 Commits

Author SHA1 Message Date
Matt Jankowski
e0c40ce8cc
Merge 04a8c3d0bd into 624c024766 2025-09-03 10:05:11 +00:00
Matt Jankowski
04a8c3d0bd Avoid return render... in api/v1/media 2025-08-29 10:11:57 -04:00

View File

@ -5,6 +5,10 @@ class Api::V1::MediaController < Api::BaseController
before_action :require_user! before_action :require_user!
before_action :set_media_attachment, except: [:create, :destroy] before_action :set_media_attachment, except: [:create, :destroy]
before_action :check_processing, except: [:create, :destroy] before_action :check_processing, except: [:create, :destroy]
with_options only: :destroy do
before_action :set_current_account_media_attachment
before_action :check_usage_by_status
end
def show def show
render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: status_code_for_media_attachment render json: @media_attachment, serializer: REST::MediaAttachmentSerializer, status: status_code_for_media_attachment
@ -26,10 +30,6 @@ class Api::V1::MediaController < Api::BaseController
end end
def destroy def destroy
@media_attachment = current_account.media_attachments.find(params[:id])
return render json: in_usage_error, status: 422 unless @media_attachment.status_id.nil?
@media_attachment.destroy @media_attachment.destroy
render_empty render_empty
end end
@ -44,6 +44,14 @@ class Api::V1::MediaController < Api::BaseController
@media_attachment = current_account.media_attachments.where(status_id: nil).find(params[:id]) @media_attachment = current_account.media_attachments.where(status_id: nil).find(params[:id])
end end
def set_current_account_media_attachment
@media_attachment = current_account.media_attachments.find(params[:id])
end
def check_usage_by_status
render json: in_usage_error, status: 422 if @media_attachment.status_id?
end
def check_processing def check_processing
render json: processing_error, status: 422 if @media_attachment.processing_failed? render json: processing_error, status: 422 if @media_attachment.processing_failed?
end end