2016-11-16 02:56:29 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-09-18 01:47:26 +10:00
|
|
|
class MediaController < ApplicationController
|
2017-05-30 02:22:22 +10:00
|
|
|
include Authorization
|
|
|
|
|
2017-04-18 04:02:00 +10:00
|
|
|
before_action :verify_permitted_status
|
2016-09-18 01:47:26 +10:00
|
|
|
|
|
|
|
def show
|
2017-04-18 04:02:00 +10:00
|
|
|
redirect_to media_attachment.file.url(:original)
|
2016-09-18 01:47:26 +10:00
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
2017-04-18 04:02:00 +10:00
|
|
|
def media_attachment
|
|
|
|
MediaAttachment.attached.find_by!(shortcode: params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def verify_permitted_status
|
2017-05-30 02:22:22 +10:00
|
|
|
authorize media_attachment.status, :show?
|
|
|
|
rescue Mastodon::NotPermittedError
|
|
|
|
# Reraise in order to get a 404 instead of a 403 error code
|
|
|
|
raise ActiveRecord::RecordNotFound
|
2016-09-18 01:47:26 +10:00
|
|
|
end
|
|
|
|
end
|