about summary refs log tree commit diff
path: root/app/lib/command_tag/commands/status_tools.rb
blob: 3c6d7137ec668301b2cb36928f7057fb6e5388d1 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# frozen_string_literal: true

module CommandTag::Commands::StatusTools
  def handle_publish_once_at_end
    return unless author_of_parent? && !@parent.published?

    PublishStatusService.new.call(@parent)
  end

  def handle_edit_once_before_save
    return unless author_of_parent?

    params = @parent.slice(*UpdateStatusService::ALLOWED_ATTRIBUTES).with_indifferent_access.compact
    params[:text] = @text
    UpdateStatusService.new.call(@parent, params)
    destroy_status!
  end
end