about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-06 00:57:25 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commitdb6ae92c0968611123813c7b14cc8ff7914ebcce (patch)
treef95552ec29bebaa0498101a8f23222a5c58233cc /app
parent726a99a6e4edc82930afb7b04ef1ebcdc9340b06 (diff)
Limit tag scope nesting to six components. Rewrite multiple consecutive delimiters to one (`::`, `:::`, ... => `:`).
Diffstat (limited to 'app')
-rw-r--r--app/services/process_hashtags_service.rb7
1 files changed, 5 insertions, 2 deletions
diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb
index 4257d9231..7f51d1fb8 100644
--- a/app/services/process_hashtags_service.rb
+++ b/app/services/process_hashtags_service.rb
@@ -6,12 +6,15 @@ class ProcessHashtagsService < BaseService
     records = []
 
     tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
+      name = name.gsub(/::+/, ':')
       component_indices = name.size.times.select {|i| name[i] == ':'}
       component_indices << name.size - 1
-      component_indices.each do |i|
-        frag = name[0..i]
+      component_indices.take(6).each_with_index do |i, nest|
+        frag = (nest != 5) ? name[0..i] : name
         tag = Tag.where(name: frag).first_or_create(name: frag)
 
+        p frag
+
         status.tags << tag
 
         next if tag.local || tag.private