Please CodeClimate

This commit is contained in:
Claire 2021-09-21 15:58:28 +02:00
parent 3ad653c4fd
commit 351629dedf
1 changed files with 5 additions and 7 deletions

View File

@ -28,13 +28,11 @@ class MediaController < ApplicationController
def set_media_attachment def set_media_attachment
id = params[:id] || params[:medium_id] id = params[:id] || params[:medium_id]
if id.nil? return if id.nil?
return
elsif id.size == 19 # SecureRandom.url_safe(14) scope = MediaAttachment.local.attached
@media_attachment = MediaAttachment.local.attached.find_by!(shortcode: id) # If id is 19 characters long, it's a shortcode, otherwise it's an identifier
else @media_attachment = id.size == 19 ? scope.find_by!(shortcode: id) : scope.find_by!(id: id)
@media_attachment = MediaAttachment.local.attached.find_by!(id: id)
end
end end
def verify_permitted_status! def verify_permitted_status!