Add policy for mute rules
This commit is contained in:
parent
c8f990e319
commit
94c9fa12fb
|
@ -21,6 +21,9 @@ class Settings::MutesController < ApplicationController
|
|||
|
||||
def destroy
|
||||
rule = MuteRule.find(params[:id])
|
||||
|
||||
authorize rule
|
||||
|
||||
rule.destroy!
|
||||
|
||||
respond_to do |format|
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MuteRulePolicy
|
||||
attr_reader :user, :mute_rule
|
||||
|
||||
def initialize(user, mute_rule)
|
||||
@user = user
|
||||
@mute_rule = mute_rule
|
||||
end
|
||||
|
||||
def destroy?
|
||||
user == mute_rule.user || user.admin?
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue