diff options
author | Claire <claire.github-309c@sitedethib.com> | 2021-10-13 15:50:24 +0200 |
---|---|---|
committer | Claire <claire.github-309c@sitedethib.com> | 2021-10-13 15:50:24 +0200 |
commit | 1665b842856811c16b904c3b99be6b141a0e1c7b (patch) | |
tree | 6fba595782a93008ed3dd6f3ac9e19b7271df6b3 /app/controllers | |
parent | 022006577027ca040f4411489821f2e3311f0db6 (diff) | |
parent | 5159ba26e485daaeded2288c1b02bd1e516e1ca6 (diff) |
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts: - `package.json`: Not really a conflict, just a glitch-soc-only dependency textually too close to an updated upstream one. - `yarn.lock`: Not really a conflict, just a glitch-soc-only dependency textually too close to an updated upstream one.
Diffstat (limited to 'app/controllers')
-rw-r--r-- | app/controllers/media_controller.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb index 772fc42cb..d2de432ba 100644 --- a/app/controllers/media_controller.rb +++ b/app/controllers/media_controller.rb @@ -28,7 +28,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! |