Add use cases for creating and destroying mute rules
This commit is contained in:
parent
48f9c01866
commit
8178d75a57
|
@ -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
|
|
@ -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 New Issue