From 9ad70025d64be2a9ce012ad155ac249dd0e4c71b Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Thu, 23 Jul 2020 18:09:06 -0500 Subject: [Revise] Rename StatusTools to ParentStatusTools for next commit --- .../command_tag/commands/parent_status_tools.rb | 82 ++++++++++++++++++++++ app/lib/command_tag/commands/status_tools.rb | 82 ---------------------- 2 files changed, 82 insertions(+), 82 deletions(-) create mode 100644 app/lib/command_tag/commands/parent_status_tools.rb delete mode 100644 app/lib/command_tag/commands/status_tools.rb (limited to 'app/lib') diff --git a/app/lib/command_tag/commands/parent_status_tools.rb b/app/lib/command_tag/commands/parent_status_tools.rb new file mode 100644 index 000000000..df3cd06c6 --- /dev/null +++ b/app/lib/command_tag/commands/parent_status_tools.rb @@ -0,0 +1,82 @@ +# frozen_string_literal: true + +# rubocop:disable Layout/ExtraSpacing +module CommandTag::Commands::ParentStatusTools + def handle_publish_once_at_end + return unless author_of_parent? && !@parent.published? + + PublishStatusService.new.call(@parent) + end + + alias handle_publish_post_once_at_end handle_publish_once_at_end + alias handle_publish_roar_once_at_end handle_publish_once_at_end + alias handle_publish_toot_once_at_end handle_publish_once_at_end + alias handle_publish_parent_once_at_end handle_publish_once_at_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 + + alias handle_edit_post_once_before_save handle_edit_once_before_save + alias handle_edit_roar_once_before_save handle_edit_once_before_save + alias handle_edit_toot_once_before_save handle_edit_once_before_save + alias handle_edit_parent_once_before_save handle_edit_once_before_save + + def handle_mute_once_at_end + return if author_of_parent? + + MuteStatusService.new.call(@account, @parent) + end + + alias handle_mute_post_once_at_end handle_mute_once_at_end + alias handle_mute_roar_once_at_end handle_mute_once_at_end + alias handle_mute_toot_once_at_end handle_mute_once_at_end + alias handle_mute_parent_once_at_end handle_mute_once_at_end + alias handle_hide_once_at_end handle_mute_once_at_end + alias handle_hide_post_once_at_end handle_mute_once_at_end + alias handle_hide_roar_once_at_end handle_mute_once_at_end + alias handle_hide_toot_once_at_end handle_mute_once_at_end + alias handle_hide_parent_once_at_end handle_mute_once_at_end + + def handle_unmute_once_at_end + return if author_of_parent? + + @account.unmute_status!(@parent) + end + + alias handle_unmute_post_once_at_end handle_unmute_once_at_end + alias handle_unmute_roar_once_at_end handle_unmute_once_at_end + alias handle_unmute_toot_once_at_end handle_unmute_once_at_end + alias handle_unmute_parent_once_at_end handle_unmute_once_at_end + alias handle_unhide_once_at_end handle_unmute_once_at_end + alias handle_unhide_post_once_at_end handle_unmute_once_at_end + alias handle_unhide_roar_once_at_end handle_unmute_once_at_end + alias handle_unhide_toot_once_at_end handle_unmute_once_at_end + alias handle_unhide_parent_once_at_end handle_unmute_once_at_end + + def handle_mute_thread_once_at_end + return if author_of_parent? + + MuteConversationService.new.call(@account, @conversation) + end + + alias handle_mute_conversation_once_at_end handle_mute_thread_once_at_end + alias handle_hide_thread_once_at_end handle_mute_thread_once_at_end + alias handle_hide_conversation_once_at_end handle_mute_thread_once_at_end + + def handle_unmute_thread_once_at_end + return if author_of_parent? || @conversation.blank? + + @account.unmute_conversation!(@conversation) + end + + alias handle_unmute_conversation_once_at_end handle_unmute_thread_once_at_end + alias handle_unhide_thread_once_at_end handle_unmute_thread_once_at_end + alias handle_unhide_conversation_once_at_end handle_unmute_thread_once_at_end +end +# rubocop:enable Layout/ExtraSpacing diff --git a/app/lib/command_tag/commands/status_tools.rb b/app/lib/command_tag/commands/status_tools.rb deleted file mode 100644 index 1691fcf53..000000000 --- a/app/lib/command_tag/commands/status_tools.rb +++ /dev/null @@ -1,82 +0,0 @@ -# frozen_string_literal: true - -# rubocop:disable Layout/ExtraSpacing -module CommandTag::Commands::StatusTools - def handle_publish_once_at_end - return unless author_of_parent? && !@parent.published? - - PublishStatusService.new.call(@parent) - end - - alias handle_publish_post_once_at_end handle_publish_once_at_end - alias handle_publish_roar_once_at_end handle_publish_once_at_end - alias handle_publish_toot_once_at_end handle_publish_once_at_end - alias handle_publish_parent_once_at_end handle_publish_once_at_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 - - alias handle_edit_post_once_before_save handle_edit_once_before_save - alias handle_edit_roar_once_before_save handle_edit_once_before_save - alias handle_edit_toot_once_before_save handle_edit_once_before_save - alias handle_edit_parent_once_before_save handle_edit_once_before_save - - def handle_mute_once_at_end - return if author_of_parent? - - MuteStatusService.new.call(@account, @parent) - end - - alias handle_mute_post_once_at_end handle_mute_once_at_end - alias handle_mute_roar_once_at_end handle_mute_once_at_end - alias handle_mute_toot_once_at_end handle_mute_once_at_end - alias handle_mute_parent_once_at_end handle_mute_once_at_end - alias handle_hide_once_at_end handle_mute_once_at_end - alias handle_hide_post_once_at_end handle_mute_once_at_end - alias handle_hide_roar_once_at_end handle_mute_once_at_end - alias handle_hide_toot_once_at_end handle_mute_once_at_end - alias handle_hide_parent_once_at_end handle_mute_once_at_end - - def handle_unmute_once_at_end - return if author_of_parent? - - @account.unmute_status!(@parent) - end - - alias handle_unmute_post_once_at_end handle_unmute_once_at_end - alias handle_unmute_roar_once_at_end handle_unmute_once_at_end - alias handle_unmute_toot_once_at_end handle_unmute_once_at_end - alias handle_unmute_parent_once_at_end handle_unmute_once_at_end - alias handle_unhide_once_at_end handle_unmute_once_at_end - alias handle_unhide_post_once_at_end handle_unmute_once_at_end - alias handle_unhide_roar_once_at_end handle_unmute_once_at_end - alias handle_unhide_toot_once_at_end handle_unmute_once_at_end - alias handle_unhide_parent_once_at_end handle_unmute_once_at_end - - def handle_mute_thread_once_at_end - return if author_of_parent? - - MuteConversationService.new.call(@account, @conversation) - end - - alias handle_mute_conversation_once_at_end handle_mute_thread_once_at_end - alias handle_hide_thread_once_at_end handle_mute_thread_once_at_end - alias handle_hide_conversation_once_at_end handle_mute_thread_once_at_end - - def handle_unmute_thread_once_at_end - return if author_of_parent? || @conversation.blank? - - @account.unmute_conversation!(@conversation) - end - - alias handle_unmute_conversation_once_at_end handle_unmute_thread_once_at_end - alias handle_unhide_thread_once_at_end handle_unmute_thread_once_at_end - alias handle_unhide_conversation_once_at_end handle_unmute_thread_once_at_end -end -# rubocop:enable Layout/ExtraSpacing -- cgit