Extract authorization policy for viewing statuses (#3150)
This commit is contained in:
parent
9a81be0d37
commit
3a2003ba86
16 changed files with 155 additions and 80 deletions
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class StatusesController < ApplicationController
|
||||
include Authorization
|
||||
|
||||
layout 'public'
|
||||
|
||||
before_action :set_account
|
||||
|
@ -30,7 +32,10 @@ class StatusesController < ApplicationController
|
|||
@stream_entry = @status.stream_entry
|
||||
@type = @stream_entry.activity_type.downcase
|
||||
|
||||
raise ActiveRecord::RecordNotFound unless @status.permitted?(current_account)
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
def check_account_suspension
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue