You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
544 B

  1. # frozen_string_literal: true
  2. class MediaController < ApplicationController
  3. include Authorization
  4. before_action :verify_permitted_status
  5. def show
  6. redirect_to media_attachment.file.url(:original)
  7. end
  8. private
  9. def media_attachment
  10. MediaAttachment.attached.find_by!(shortcode: params[:id])
  11. end
  12. def verify_permitted_status
  13. authorize media_attachment.status, :show?
  14. rescue Mastodon::NotPermittedError
  15. # Reraise in order to get a 404 instead of a 403 error code
  16. raise ActiveRecord::RecordNotFound
  17. end
  18. end