Gab-Social/app/services/process_hashtags_service.rb
mgabdev ba8e8942dc Added Gab Deck initial mvp
• Added:
- Gab Deck initial mvp
2020-12-05 23:47:48 -05:00

18 lines
511 B
Ruby

# 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?
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