about summary refs log tree commit diff
path: root/app/services/process_hashtags_service.rb
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-05 15:20:05 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-05 17:13:14 +0100
commit48b9619439818ecb344ae33c9c31a55ecb1aa27a (patch)
treeef350e3ebf2563adbe4d57778a08f561d912415f /app/services/process_hashtags_service.rb
parent62292797eccc5bcf47abae9f4daaa2c186660644 (diff)
Adding hashtags
Diffstat (limited to 'app/services/process_hashtags_service.rb')
-rw-r--r--app/services/process_hashtags_service.rb11
1 files changed, 11 insertions, 0 deletions
diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb
new file mode 100644
index 000000000..8c68ce989
--- /dev/null
+++ b/app/services/process_hashtags_service.rb
@@ -0,0 +1,11 @@
+class ProcessHashtagsService < BaseService
+  def call(status, tags = [])
+    if status.local?
+      tags = status.text.scan(Tag::HASHTAG_RE).map(&:first)
+    end
+
+    tags.map(&:downcase).each do |tag|
+      status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
+    end
+  end
+end