* Wip * Wip * Wip: History * Wip: テストコード作成 * Fix test * Wip * Wip * Wip * Fix test * Wip * Wip * Wip * Wip * なんとか完成、これから動作確認 * spell miss * Change ng rule timings * Fix test * Wip * Fix test * Wip * Fix form * 表示まわりの改善
This commit is contained in:
parent
0779c748a6
commit
7d96d5828e
56 changed files with 2062 additions and 42 deletions
28
app/helpers/ng_rule_helper.rb
Normal file
28
app/helpers/ng_rule_helper.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module NgRuleHelper
|
||||
def check_invalid_status_for_ng_rule!(account, **options)
|
||||
(check_for_ng_rule!(account, **options) { |rule| !rule.check_status_or_record! }).none?
|
||||
end
|
||||
|
||||
def check_invalid_reaction_for_ng_rule!(account, **options)
|
||||
(check_for_ng_rule!(account, **options) { |rule| !rule.check_reaction_or_record! }).none?
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def check_for_ng_rule!(account, **options, &block)
|
||||
NgRule.cached_rules
|
||||
.map { |raw_rule| Admin::NgRule.new(raw_rule, account, **options) }
|
||||
.filter(&block)
|
||||
end
|
||||
|
||||
def do_account_action_for_rule!(account, action)
|
||||
case action
|
||||
when :silence
|
||||
account.silence!
|
||||
when :suspend
|
||||
account.suspend!
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue