about summary refs log tree commit diff
path: root/app/policies/status_policy.rb
diff options
context:
space:
mode:
authorSurinna Curtis <ekiru.0@gmail.com>2017-11-16 01:38:26 -0600
committerGitHub <noreply@github.com>2017-11-16 01:38:26 -0600
commitee560abdbe7a2caf0f7ac6137faf248bbaff9a93 (patch)
treefcd9bdb5ba49ab7a6a79590c74db858ae77b4239 /app/policies/status_policy.rb
parent88627fd7aa2493a6890d60a5965459e4c7fe6fe9 (diff)
parent35fbdc36f92b610e8a73e2acb220e87cf5fc83b0 (diff)
Merge pull request #216 from glitch-soc/merge-upstream-3023725
Merge upstream at commit 3023725
Diffstat (limited to 'app/policies/status_policy.rb')
-rw-r--r--app/policies/status_policy.rb37
1 files changed, 19 insertions, 18 deletions
diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb
index f4a5e7c6c..8e0c1eef1 100644
--- a/app/policies/status_policy.rb
+++ b/app/policies/status_policy.rb
@@ -1,22 +1,19 @@
 # frozen_string_literal: true
 
-class StatusPolicy
-  attr_reader :account, :status
-
-  def initialize(account, status)
-    @account = account
-    @status = status
+class StatusPolicy < ApplicationPolicy
+  def index?
+    staff?
   end
 
   def show?
     return false if local_only? && account.nil?
 
     if direct?
-      owned? || status.mentions.where(account: account).exists?
+      owned? || record.mentions.where(account: current_account).exists?
     elsif private?
-      owned? || account&.following?(status.account) || status.mentions.where(account: account).exists?
+      owned? || current_account&.following?(author) || record.mentions.where(account: current_account).exists?
     else
-      account.nil? || !status.account.blocking?(account)
+      current_account.nil? || !author.blocking?(current_account)
     end
   end
 
@@ -25,30 +22,34 @@ class StatusPolicy
   end
 
   def destroy?
-    admin? || owned?
+    staff? || owned?
   end
 
   alias unreblog? destroy?
 
-  private
-
-  def admin?
-    account&.user&.admin?
+  def update?
+    staff?
   end
 
+  private
+
   def direct?
-    status.direct_visibility?
+    record.direct_visibility?
   end
 
   def owned?
-    status.account.id == account&.id
+    author.id == current_account&.id
   end
 
   def private?
-    status.private_visibility?
+    record.private_visibility?
+  end
+
+  def author
+    record.account
   end
   
   def local_only?
-    status.local_only?
+    record.local_only?
   end
 end