]> cat aescling's git repositories - mastodon.git/blob - app/controllers/media_controller.rb
Do no retry web push workers if the server returns a 4xx response (#9434)
[mastodon.git] / app / controllers / media_controller.rb
1 # frozen_string_literal: true
2
3 class MediaController < ApplicationController
4 include Authorization
5
6 before_action :set_media_attachment
7 before_action :verify_permitted_status!
8
9 def show
10 redirect_to @media_attachment.file.url(:original)
11 end
12
13 def player
14 @body_classes = 'player'
15 raise ActiveRecord::RecordNotFound unless @media_attachment.video? || @media_attachment.gifv?
16 end
17
18 private
19
20 def set_media_attachment
21 @media_attachment = MediaAttachment.attached.find_by!(shortcode: params[:id] || params[:medium_id])
22 end
23
24 def verify_permitted_status!
25 authorize @media_attachment.status, :show?
26 rescue Mastodon::NotPermittedError
27 # Reraise in order to get a 404 instead of a 403 error code
28 raise ActiveRecord::RecordNotFound
29 end
30 end
This page took 0.069647 seconds and 4 git commands to generate.