about summary refs log tree commit diff
path: root/app/services/process_hashtags_service.rb
blob: df30f73ae86d5896f0c026e2a21f079105ca79b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
class ProcessHashtagsService < BaseService
  def call(status, tags = [])
    if status.local?
      tags = status.text.scan(Tag::HASHTAG_RE).map(&:first)
    end

    tags.map(&:downcase).uniq.each do |tag|
      status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
    end
  end
end