about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-14 14:09:33 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:18 -0500
commit79535cb863d2f956bff2af8449f10da4aede4ede (patch)
treec609880ad160a4a8105f8076a1139d63884a83c1 /app/lib
parente3b316dd3e797a9c266fc1ec5e104845df1da9c6 (diff)
[Feature] Add support for unlisted and out-of-body tags
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/command_tag/command/status_tools.rb24
1 files changed, 24 insertions, 0 deletions
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)