about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/application_controller.rb7
-rw-r--r--app/lib/feed_manager.rb1
-rw-r--r--app/models/user.rb4
-rw-r--r--app/services/fan_out_on_write_service.rb4
4 files changed, 14 insertions, 2 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb
index d83690e1b..d5eaecdb1 100644
--- a/app/controllers/application_controller.rb
+++ b/app/controllers/application_controller.rb
@@ -2,4 +2,11 @@ class ApplicationController < ActionController::Base
   # Prevent CSRF attacks by raising an exception.
   # For APIs, you may want to use :null_session instead.
   protect_from_forgery with: :exception
+
+  # Profiling
+  before_action do
+    if current_user && current_user.admin?
+      Rack::MiniProfiler.authorize_request
+    end
+  end
 end
diff --git a/app/lib/feed_manager.rb b/app/lib/feed_manager.rb
index eaa9393d5..a19d06a85 100644
--- a/app/lib/feed_manager.rb
+++ b/app/lib/feed_manager.rb
@@ -6,6 +6,7 @@ class FeedManager
   end
 
   def self.filter_status?(status, follower)
+    replied_to_user = status.reply? ? status.thread.account : nil
     (status.reply? && !(follower.id = replied_to_user.id || follower.following?(replied_to_user)))
   end
 end
diff --git a/app/models/user.rb b/app/models/user.rb
index b17eabcc4..a80efb50d 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -7,4 +7,8 @@ class User < ActiveRecord::Base
   validates :account, presence: true
 
   has_many :oauth_applications, class_name: 'Doorkeeper::Application', as: :owner
+
+  def admin?
+    self.admin
+  end
 end
diff --git a/app/services/fan_out_on_write_service.rb b/app/services/fan_out_on_write_service.rb
index 4bb3f0a10..c8c775b93 100644
--- a/app/services/fan_out_on_write_service.rb
+++ b/app/services/fan_out_on_write_service.rb
@@ -3,7 +3,7 @@ class FanOutOnWriteService < BaseService
   # @param [Status] status
   def call(status)
     deliver_to_self(status) if status.account.local?
-    deliver_to_followers(status, status.reply? ? status.thread.account : nil)
+    deliver_to_followers(status)
     deliver_to_mentioned(status)
   end
 
@@ -13,7 +13,7 @@ class FanOutOnWriteService < BaseService
     push(:home, status.account.id, status)
   end
 
-  def deliver_to_followers(status, replied_to_user)
+  def deliver_to_followers(status)
     status.account.followers.each do |follower|
       next if !follower.local? || FeedManager.filter_status?(status, follower)
       push(:home, follower.id, status)