about summary refs log tree commit diff
path: root/app/controllers/media_controller.rb
diff options
context:
space:
mode:
authorReverite <github@reverite.sh>2019-06-26 20:31:07 -0700
committerReverite <github@reverite.sh>2019-06-26 20:31:07 -0700
commit3fa90982efda2109ddf90d81f5ed3449f8282642 (patch)
treee5514f4c72c9ffb44059a2afb7fdf24d0348bbd4 /app/controllers/media_controller.rb
parent714940de498e93a8bf40dcda1835217df18741bf (diff)
parent9ef25877dfda12cf31ec586294e4d4908f5be4f0 (diff)
Merge branch 'glitch' into production
Diffstat (limited to 'app/controllers/media_controller.rb')
-rw-r--r--app/controllers/media_controller.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb
index a245db2d1..d44b52d26 100644
--- a/app/controllers/media_controller.rb
+++ b/app/controllers/media_controller.rb
@@ -7,6 +7,8 @@ class MediaController < ApplicationController
 
   before_action :set_media_attachment
   before_action :verify_permitted_status!
+  before_action :check_playable, only: :player
+  before_action :allow_iframing, only: :player
 
   content_security_policy only: :player do |p|
     p.frame_ancestors(false)
@@ -18,8 +20,6 @@ class MediaController < ApplicationController
 
   def player
     @body_classes = 'player'
-    response.headers['X-Frame-Options'] = 'ALLOWALL'
-    raise ActiveRecord::RecordNotFound unless @media_attachment.video? || @media_attachment.gifv?
   end
 
   private
@@ -34,4 +34,12 @@ class MediaController < ApplicationController
     # Reraise in order to get a 404 instead of a 403 error code
     raise ActiveRecord::RecordNotFound
   end
+
+  def check_playable
+    not_found unless @media_attachment.larger_media_format?
+  end
+
+  def allow_iframing
+    response.headers['X-Frame-Options'] = 'ALLOWALL'
+  end
 end