2023-10-28 08:16:03 -07:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module UseCase
|
|
|
|
module Reaction
|
|
|
|
class Create < UseCase::Base
|
2024-03-19 14:06:57 -07:00
|
|
|
option :source_user_id, type: Types::Coercible::Integer
|
2023-10-28 08:16:03 -07:00
|
|
|
option :target, type: Types.Instance(::Answer) | Types.Instance(::Comment)
|
|
|
|
option :content, type: Types::Coercible::String, optional: true
|
|
|
|
|
|
|
|
def call
|
|
|
|
reaction = source_user.smile target
|
|
|
|
|
|
|
|
{
|
|
|
|
status: 201,
|
|
|
|
resource: reaction,
|
|
|
|
}
|
|
|
|
end
|
2024-03-19 14:06:57 -07:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def source_user
|
|
|
|
@source_user ||= ::User.find(source_user_id)
|
|
|
|
end
|
2023-10-28 08:16:03 -07:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|