2016-11-15 16:56:29 +01:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-11-05 15:20:05 +01:00
|
|
|
class ProcessHashtagsService < BaseService
|
|
|
|
def call(status, tags = [])
|
2017-05-12 22:03:43 -04:00
|
|
|
tags = status.text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
|
2016-11-05 15:20:05 +01:00
|
|
|
|
2017-01-23 21:36:08 +01:00
|
|
|
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |tag|
|
2016-11-05 15:20:05 +01:00
|
|
|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
|
|
|
|
end
|
2016-12-11 22:49:25 +01:00
|
|
|
|
|
|
|
status.update(sensitive: true) if tags.include?('nsfw')
|
2016-11-05 15:20:05 +01:00
|
|
|
end
|
|
|
|
end
|