Extract authorization policy for viewing statuses (#3150)

This commit is contained in:
Jack Jennings authored and Eugen Rochko committed 2017-05-29 18:22:22 +02:00
1 parent 9a81be0d37
commit 3a2003ba86
16 files changed
+155 -80

No files matched your search

+6 -1
View File
@@ -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