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 Api::V1::StatusesController < ApiController
|
||||
include Authorization
|
||||
|
||||
before_action :authorize_if_got_token, except: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite, :mute, :unmute]
|
||||
before_action -> { doorkeeper_authorize! :write }, only: [:create, :destroy, :reblog, :unreblog, :favourite, :unfavourite, :mute, :unmute]
|
||||
before_action :require_user!, except: [:show, :context, :card, :reblogged_by, :favourited_by]
|
||||
|
@ -130,7 +132,10 @@ class Api::V1::StatusesController < ApiController
|
|||
|
||||
def set_status
|
||||
@status = Status.find(params[:id])
|
||||
raise ActiveRecord::RecordNotFound unless @status.permitted?(current_account)
|
||||
authorize @status, :show?
|
||||
rescue Mastodon::NotPermittedError
|
||||
# Reraise in order to get a 404 instead of a 403 error code
|
||||
raise ActiveRecord::RecordNotFound
|
||||
end
|
||||
|
||||
def set_conversation
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue