diff --git a/app/policies/status_policy.rb b/app/policies/status_policy.rb index 038a2f81..e5a6e557 100644 --- a/app/policies/status_policy.rb +++ b/app/policies/status_policy.rb @@ -12,10 +12,16 @@ class StatusPolicy < ApplicationPolicy end def show? - if requires_mention? - owned? || mention_exists? - elsif private? - owned? || following_author? || mention_exists? + return true if owned? || staff? + + if private? + if record.group_id + private_group_member? + else + following_author? + end + elsif requires_mention? + mention_exists? else current_account.nil? || !author_blocking? end @@ -84,6 +90,14 @@ class StatusPolicy < ApplicationPolicy @preloaded_relations[:following] ? @preloaded_relations[:following][author.id] : current_account.following?(author) end + def private_group_member? + return false if current_account.nil? + return false if record.group_id.nil? + return true if owned? + + GroupAccount.where(group_id: record.group_id, account: current_account).exists? + end + def author record.account end