2016-11-16 02:56:29 +11:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-06 01:20:05 +11:00
|
|
|
class ProcessHashtagsService < BaseService
|
|
|
|
def call(status, tags = [])
|
2017-05-20 04:19:14 +10:00
|
|
|
tags = Extractor.extract_hashtags(status.text) if status.local?
|
2016-11-06 01:20:05 +11:00
|
|
|
|
2017-01-24 07:36:08 +11:00
|
|
|
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |tag|
|
2016-11-06 01:20:05 +11:00
|
|
|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
|
|
|
|
end
|
2016-12-12 08:49:25 +11:00
|
|
|
|
|
|
|
status.update(sensitive: true) if tags.include?('nsfw')
|
2016-11-06 01:20:05 +11:00
|
|
|
end
|
|
|
|
end
|