Gab-Social/app/services/process_hashtags_service.rb

18 lines
511 B
Ruby
Raw Normal View History

2019-07-02 07:10:25 +00:00
# frozen_string_literal: true
class ProcessHashtagsService < BaseService
def call(status, tags = [])
tags = Extractor.extract_hashtags(status.text) + Extractor.extract_cashtags(status.text) if status.local?
2019-07-02 07:10:25 +00:00
records = []
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
tag = Tag.where(name: name).first_or_create(name: name)
status.tags << tag
records << tag
end
return unless status.public_visibility? || status.unlisted_visibility?
end
end