about summary refs log tree commit diff
path: root/app/controllers/media_controller.rb
blob: fa1daf012a6891d16d8d60a93e30cbce3f1442a0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# frozen_string_literal: true

class MediaController < ApplicationController
  before_action :verify_permitted_status

  def show
    redirect_to media_attachment.file.url(:original)
  end

  private

  def media_attachment
    MediaAttachment.attached.find_by!(shortcode: params[:id])
  end

  def verify_permitted_status
    raise ActiveRecord::RecordNotFound unless media_attachment.status.permitted?(current_account)
  end
end