2016-11-16 00:56:29 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-05 23:20:05 +09:00
|
|
|
class ProcessHashtagsService < BaseService
|
|
|
|
def call(status, tags = [])
|
2016-11-16 00:56:29 +09:00
|
|
|
tags = status.text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
|
2016-11-05 23:20:05 +09:00
|
|
|
|
2016-11-26 23:24:14 +09:00
|
|
|
tags.map { |str| str.mb_chars.downcase }.uniq.each do |tag|
|
2016-11-05 23:20:05 +09:00
|
|
|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
|
|
|
|
end
|
2016-12-12 06:49:25 +09:00
|
|
|
|
|
|
|
status.update(sensitive: true) if tags.include?('nsfw')
|
2016-11-05 23:20:05 +09:00
|
|
|
end
|
|
|
|
end
|