mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 14:39:52 +01:00
Add policy for mute rules
This commit is contained in:
parent
c8f990e319
commit
94c9fa12fb
2 changed files with 17 additions and 0 deletions
|
@ -21,6 +21,9 @@ class Settings::MutesController < ApplicationController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
rule = MuteRule.find(params[:id])
|
rule = MuteRule.find(params[:id])
|
||||||
|
|
||||||
|
authorize rule
|
||||||
|
|
||||||
rule.destroy!
|
rule.destroy!
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
|
|
14
app/policies/mute_rule_policy.rb
Normal file
14
app/policies/mute_rule_policy.rb
Normal file
|
@ -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 a new issue