mirror of
https://github.com/Retrospring/retrospring.git
synced 2024-11-20 16:09:52 +01:00
29 lines
537 B
Ruby
29 lines
537 B
Ruby
# frozen_string_literal: true
|
|
|
|
module UseCase
|
|
module Answer
|
|
class Unpin < UseCase::Base
|
|
option :user, type: Types.Instance(::User)
|
|
option :answer, type: Types.Instance(::Answer)
|
|
|
|
def call
|
|
authorize!(:unpin, user, answer)
|
|
check_pinned!
|
|
|
|
answer.pinned_at = nil
|
|
answer.save!
|
|
|
|
{
|
|
status: 200,
|
|
resource: nil,
|
|
}
|
|
end
|
|
|
|
private
|
|
|
|
def check_pinned!
|
|
raise ::Errors::BadRequest if answer.pinned_at.nil?
|
|
end
|
|
end
|
|
end
|
|
end
|