1
0
Fork 1
forked from fedi/mastodon
mastodon/app/policies/status_policy.rb
Eugen Rochko f62539ce5c
Remove most behaviour disparities between blocks and mutes (#7231)
* Remove most behaviour disparities between blocks and mutes

The only differences between block and mute should be:

- Mutes can optionally NOT affect notifications
- Mutes should not be visible to the muted

Fix #7230
Fix #5713

* Do not allow boosting someone you blocked

Fix #7248

* Do not allow favouriting someone you blocked

* Fix nil error in StatusPolicy
2018-05-02 15:50:20 +02:00

54 lines
916 B
Ruby

# frozen_string_literal: true
class StatusPolicy < ApplicationPolicy
def index?
staff?
end
def show?
if direct?
owned? || record.mentions.where(account: current_account).exists?
elsif private?
owned? || current_account&.following?(author) || record.mentions.where(account: current_account).exists?
else
current_account.nil? || !author.blocking?(current_account)
end
end
def reblog?
!direct? && (!private? || owned?) && show? && !current_account&.blocking?(author)
end
def favourite?
show? && !current_account&.blocking?(author)
end
def destroy?
staff? || owned?
end
alias unreblog? destroy?
def update?
staff?
end
private
def direct?
record.direct_visibility?
end
def owned?
author.id == current_account&.id
end
def private?
record.private_visibility?
end
def author
record.account
end
end