Add use cases for creating and destroying mute rules

This commit is contained in:
Karina Kwiatek 2022-07-24 11:01:22 +02:00 committed by Andreas Nedbal
parent 48f9c01866
commit 8178d75a57
2 changed files with 40 additions and 0 deletions

View 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

View 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