mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 08:29:53 +01:00
Add use cases for creating and destroying mute rules
This commit is contained in:
parent
7f9764a681
commit
8d650bb20f
2 changed files with 47 additions and 0 deletions
25
lib/use_case/mute_rule/create.rb
Normal file
25
lib/use_case/mute_rule/create.rb
Normal file
|
@ -0,0 +1,25 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "use_case/base"
|
||||
require "errors"
|
||||
|
||||
module UseCase
|
||||
module MuteRule
|
||||
class Create < UseCase::Base
|
||||
option :user, type: Types.Instance(::User)
|
||||
option :phrase, type: Types::Coercible::String
|
||||
|
||||
def call
|
||||
rule = MuteRule.create(
|
||||
user:,
|
||||
muted_phrase: phrase
|
||||
)
|
||||
|
||||
{
|
||||
status: 201,
|
||||
resource: rule,
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
22
lib/use_case/mute_rule/destroy.rb
Normal file
22
lib/use_case/mute_rule/destroy.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "use_case/base"
|
||||
require "errors"
|
||||
|
||||
module UseCase
|
||||
module MuteRule
|
||||
class Destroy < UseCase::Base
|
||||
option :user, type: Types.Instance(::User)
|
||||
option :rule, Types.Instance(::MuteRule)
|
||||
|
||||
def call
|
||||
rule.destroy!
|
||||
|
||||
{
|
||||
status: 204,
|
||||
resource: nil
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue