mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-02-13 21:33:20 +01:00
Add use cases for creating and destroying mute rules
This commit is contained in:
parent
48f9c01866
commit
8178d75a57
2 changed files with 40 additions and 0 deletions
22
lib/use_case/mute_rule/create.rb
Normal file
22
lib/use_case/mute_rule/create.rb
Normal file
|
@ -0,0 +1,22 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
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
|
18
lib/use_case/mute_rule/destroy.rb
Normal file
18
lib/use_case/mute_rule/destroy.rb
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module UseCase
|
||||
module MuteRule
|
||||
class Destroy < UseCase::Base
|
||||
option :rule, Types.Instance(::MuteRule)
|
||||
|
||||
def call
|
||||
rule.destroy!
|
||||
|
||||
{
|
||||
status: 204,
|
||||
resource: nil
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue