chinwagsocial/app/services/process_hashtags_service.rb

12 lines
298 B
Ruby
Raw Normal View History

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