1 # frozen_string_literal: true
3 class MediaController
< ApplicationController
6 skip_before_action
:store_current_location
7 skip_before_action
:require_functional!
9 before_action
:authenticate_user!
, if: :whitelist_mode?
10 before_action
:set_media_attachment
11 before_action
:verify_permitted_status!
12 before_action
:check_playable, only
: :player
13 before_action
:allow_iframing, only
: :player
15 content_security_policy only
: :player do |p
|
16 p
.frame_ancestors(false)
20 redirect_to
@media_attachment.file
.url(:original)
24 @body_classes = 'player'
29 def set_media_attachment
30 @media_attachment = MediaAttachment
.attached
.find_by!
(shortcode
: params
[:id] || params
[:medium_id])
33 def verify_permitted_status!
34 authorize
@media_attachment.status
, :show?
35 rescue Mastodon
::NotPermittedError
36 raise ActiveRecord
::RecordNotFound
40 not_found
unless @media_attachment.larger_media_format
?
44 response
.headers
['X-Frame-Options'] = 'ALLOWALL'