mirror of
https://github.com/mastodon/mastodon.git
synced 2024-10-19 01:01:23 +09:00
Merge 5c30c34a4c
into 8b56509625
This commit is contained in:
commit
31a12f4a22
@ -6,11 +6,15 @@ class AccountWarningPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def appeal?
|
||||
target? && record.created_at >= Appeal::MAX_STRIKE_AGE.ago
|
||||
target? && eligible_for_appeal?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def eligible_for_appeal?
|
||||
record.created_at >= Appeal::MAX_STRIKE_AGE.ago
|
||||
end
|
||||
|
||||
def target?
|
||||
record.target_account_id == current_account&.id
|
||||
end
|
||||
|
@ -12,7 +12,7 @@ class Admin::StatusPolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def show?
|
||||
role.can?(:manage_reports, :manage_users) && (record.public_visibility? || record.unlisted_visibility? || record.reported? || viewable_through_normal_policy?)
|
||||
role.can?(:manage_reports, :manage_users) && eligible_to_show?
|
||||
end
|
||||
|
||||
def destroy?
|
||||
@ -29,6 +29,10 @@ class Admin::StatusPolicy < ApplicationPolicy
|
||||
|
||||
private
|
||||
|
||||
def eligible_to_show?
|
||||
record.distributable? || record.reported? || viewable_through_normal_policy?
|
||||
end
|
||||
|
||||
def viewable_through_normal_policy?
|
||||
StatusPolicy.new(current_account, record, @preloaded_relations).show?
|
||||
end
|
||||
|
@ -4,6 +4,16 @@ class BackupPolicy < ApplicationPolicy
|
||||
MIN_AGE = 6.days
|
||||
|
||||
def create?
|
||||
user_signed_in? && current_user.backups.where(created_at: MIN_AGE.ago..).count.zero?
|
||||
user_signed_in? && eligible_for_backup?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def eligible_for_backup?
|
||||
current_user
|
||||
.backups
|
||||
.where(created_at: MIN_AGE.ago..)
|
||||
.count
|
||||
.zero?
|
||||
end
|
||||
end
|
||||
|
@ -2,6 +2,16 @@
|
||||
|
||||
class PollPolicy < ApplicationPolicy
|
||||
def vote?
|
||||
StatusPolicy.new(current_account, record.status).show? && !current_account.blocking?(record.account) && !record.account.blocking?(current_account)
|
||||
viewable_through_normal_policy? && accounts_not_blocking?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def viewable_through_normal_policy?
|
||||
StatusPolicy.new(current_account, record.status).show?
|
||||
end
|
||||
|
||||
def accounts_not_blocking?
|
||||
!current_account.blocking?(record.account) && !record.account.blocking?(current_account)
|
||||
end
|
||||
end
|
||||
|
@ -10,10 +10,16 @@ class UserRolePolicy < ApplicationPolicy
|
||||
end
|
||||
|
||||
def update?
|
||||
role.can?(:manage_roles) && (role.overrides?(record) || role.id == record.id)
|
||||
role.can?(:manage_roles) && (role.overrides?(record) || self_editing?)
|
||||
end
|
||||
|
||||
def destroy?
|
||||
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && role.id != record.id
|
||||
!record.everyone? && role.can?(:manage_roles) && role.overrides?(record) && !self_editing?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def self_editing?
|
||||
role.id == record.id
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user