mastodon/app/services/process_hashtags_service.rb

14 lines
422 B
Ruby
Raw Normal View History

# frozen_string_literal: true
2016-11-05 15:20:05 +01:00
class ProcessHashtagsService < BaseService
def call(status, tags = [])
tags = Extractor.extract_hashtags(status.text) if status.local?
2016-11-05 15:20:05 +01:00
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
TrendingTags.record_use!(tag, status.account, status.created_at)
2016-11-05 15:20:05 +01:00
end
end
end