diff --git a/lib/use_case/mute_rule/create.rb b/lib/use_case/mute_rule/create.rb new file mode 100644 index 00000000..980d1081 --- /dev/null +++ b/lib/use_case/mute_rule/create.rb @@ -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 diff --git a/lib/use_case/mute_rule/destroy.rb b/lib/use_case/mute_rule/destroy.rb new file mode 100644 index 00000000..841234c6 --- /dev/null +++ b/lib/use_case/mute_rule/destroy.rb @@ -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