about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-06 01:56:19 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commit1ed7aca171d455687e32b8abfed2e6b8db25d110 (patch)
treeb702fd1b11ddd6ee9793c48f7e4b598c9bca777d /app/lib
parenta1be3a11a97fc4119da4f0f951e2e9447bb7a647 (diff)
Add `parent:tag` bangtag
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/bangtags.rb13
1 files changed, 9 insertions, 4 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 02df8610c..d18141e71 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -219,7 +219,7 @@ class Bangtags
         when 'tag'
           chunk = nil
           tags = cmd[1..-1].map {|t| t.gsub('.', ':')}
-          add_tags(*tags)
+          add_tags(status, *tags)
         when 'thread'
           chunk = nil
           next if cmd[1].nil?
@@ -288,6 +288,11 @@ class Bangtags
           case cmd[1].downcase
           when 'permalink'
             chunk = TagManager.instance.url_for(@parent_status)
+          when 'tag'
+            chunk = nil
+            next unless @parent_status.account.id == @account.id
+            tags = cmd[2..-1].map {|t| t.gsub('.', ':')}
+            add_tags(@parent_status, *tags)
           when 'emoji'
             @parent_status.emojis.each do |theirs|
               ours = CustomEmoji.find_or_initialize_by(shortcode: theirs.shortcode, domain: nil)
@@ -395,7 +400,7 @@ class Bangtags
           status.visibility = :direct
           @vore_stack.push('_draft')
           @component_stack.push(:var)
-          add_tags('self:draft')
+          add_tags(status, 'self:draft')
         when 'visibility'
           chunk = nil
           next if cmd[1].nil?
@@ -498,10 +503,10 @@ class Bangtags
     end
   end
 
-  def add_tags(*tags)
+  def add_tags(to_status, *tags)
     records = []
     valid_name = /^[[:word:]:_\-]*[[:alpha:]:_·\-][[:word:]:_\-]*$/
     tags = tags.select {|t| t.present? && valid_name.match?(t)}.uniq
-    ProcessHashtagsService.new.call(status, tags)
+    ProcessHashtagsService.new.call(to_status, tags)
   end
 end