Fix error when rendering public pages with media attachments (#16763)
* Add tests * Fix error when rendering public pages with media attachments * Add tests * Fix tests * Please CodeClimate
This commit is contained in:
parent
8818622feb
commit
5159ba26e4
5 changed files with 102 additions and 38 deletions
|
@ -27,7 +27,12 @@ class MediaController < ApplicationController
|
|||
private
|
||||
|
||||
def set_media_attachment
|
||||
@media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id])
|
||||
id = params[:id] || params[:medium_id]
|
||||
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!
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue