about summary refs log tree commit diff
path: root/app/controllers
diff options
context:
space:
mode:
authorDavid Yip <yipdw@member.fsf.org>2018-02-17 00:02:37 -0600
committerDavid Yip <yipdw@member.fsf.org>2018-02-17 00:02:37 -0600
commit3d033a468748338b6036cb24bb00ea4e88656ae6 (patch)
treea1b3bcbe599a9298f4167769ea2c197f7ca596e6 /app/controllers
parente9052ceaafff786590fb66bee4550878cfb5a0df (diff)
parentc770b503c0e75015f8ba1ca90755b19326b64c3d (diff)
Merge remote-tracking branch 'tootsuite/master' into merge-upstream
 Conflicts:
	Gemfile
	config/locales/simple_form.pl.yml
Diffstat (limited to 'app/controllers')
-rw-r--r--app/controllers/media_controller.rb18
1 files changed, 12 insertions, 6 deletions
diff --git a/app/controllers/media_controller.rb b/app/controllers/media_controller.rb
index f652f5ace..88c7232dd 100644
--- a/app/controllers/media_controller.rb
+++ b/app/controllers/media_controller.rb
@@ -3,20 +3,26 @@
 class MediaController < ApplicationController
   include Authorization
 
-  before_action :verify_permitted_status
+  before_action :set_media_attachment
+  before_action :verify_permitted_status!
 
   def show
-    redirect_to media_attachment.file.url(:original)
+    redirect_to @media_attachment.file.url(:original)
+  end
+
+  def player
+    @body_classes = 'player'
+    raise ActiveRecord::RecordNotFound unless @media_attachment.video? || @media_attachment.gifv?
   end
 
   private
 
-  def media_attachment
-    MediaAttachment.attached.find_by!(shortcode: params[:id])
+  def set_media_attachment
+    @media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id])
   end
 
-  def verify_permitted_status
-    authorize media_attachment.status, :show?
+  def verify_permitted_status!
+    authorize @media_attachment.status, :show?
   rescue Mastodon::NotPermittedError
     # Reraise in order to get a 404 instead of a 403 error code
     raise ActiveRecord::RecordNotFound