2016-11-05 14:20:05 +00:00
|
|
|
class ProcessHashtagsService < BaseService
|
|
|
|
def call(status, tags = [])
|
|
|
|
if status.local?
|
|
|
|
tags = status.text.scan(Tag::HASHTAG_RE).map(&:first)
|
|
|
|
end
|
|
|
|
|
2016-11-05 21:09:51 +00:00
|
|
|
tags.map(&:downcase).uniq.each do |tag|
|
2016-11-05 14:20:05 +00:00
|
|
|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|