process_hashtags_service.rb 592 B

123456789101112131415161718192021
  1. # frozen_string_literal: true
  2. class ProcessHashtagsService < BaseService
  3. def call(status, tags = [])
  4. tags = Extractor.extract_hashtags(status.text) if status.local?
  5. records = []
  6. Tag.find_or_create_by_names(tags) do |tag|
  7. status.tags << tag
  8. records << tag
  9. TrendingTags.record_use!(tag, status.account, status.created_at) if status.public_visibility?
  10. end
  11. return unless status.distributable?
  12. status.account.featured_tags.where(tag_id: records.map(&:id)).each do |featured_tag|
  13. featured_tag.increment(status.created_at)
  14. end
  15. end
  16. end