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
id = params[:id] || params[:medium_id]
if id.nil?
return
elsif id.size == 19 # SecureRandom.url_safe(14)
@media_attachment = MediaAttachment.local.attached.find_by!(shortcode: id)
else
@media_attachment = MediaAttachment.local.attached.find_by!(id: id)
end
return if id.nil?
scope = MediaAttachment.local.attached
# If id is 19 characters long, it's a shortcode, otherwise it's an identifier
@media_attachment = id.size == 19 ? scope.find_by!(shortcode: id) : scope.find_by!(id: id)
end
def verify_permitted_status!