Fix error when rendering public pages with media attachments

This commit is contained in:
Claire 2021-09-21 14:13:05 +02:00
parent e521eae200
commit 349b708872
2 changed files with 9 additions and 2 deletions

View File

@ -27,7 +27,14 @@ class MediaController < ApplicationController
private private
def set_media_attachment def set_media_attachment
@media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id]) 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
end end
def verify_permitted_status! def verify_permitted_status!

View File

@ -218,7 +218,7 @@ class MediaAttachment < ApplicationRecord
end end
def to_param def to_param
shortcode shortcode.presence || id&.to_s
end end
def focus=(point) def focus=(point)