From 79535cb863d2f956bff2af8449f10da4aede4ede Mon Sep 17 00:00:00 2001 From: Fire Demon Date: Fri, 14 Aug 2020 14:09:33 -0500 Subject: [Feature] Add support for unlisted and out-of-body tags --- app/lib/command_tag/command/status_tools.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'app/lib') diff --git a/app/lib/command_tag/command/status_tools.rb b/app/lib/command_tag/command/status_tools.rb index a323138ea..1727a956e 100644 --- a/app/lib/command_tag/command/status_tools.rb +++ b/app/lib/command_tag/command/status_tools.rb @@ -49,6 +49,30 @@ module CommandTag::Command::StatusTools alias handle_notice_before_save handle_notify_before_save + def handle_tags_before_save(args) + return if args.blank? + + cmd = args.shift.downcase + args.select! { |tag| tag =~ /\A(#{Tag::HASHTAG_NAME_RE})\z/i } + + case cmd + when 'add', 'a', '+' + ProcessHashtagsService.new.call(@status, args) + when 'del', 'remove', 'rm', 'r', 'd', '-' + RemoveHashtagsService.new.call(@status, args) + end + end + + def handle_tag_before_save(args) + args.unshift('add') + handle_tags_before_save(args) + end + + def handle_untag_before_save(args) + args.unshift('del') + handle_tags_before_save(args) + end + private def resolve_mention(mention_text) -- cgit