mirror of
https://framagit.org/tykayn/mastodon.git
synced 2023-08-25 08:33:12 +02:00
14 lines
404 B
Ruby
14 lines
404 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ProcessHashtagsService < BaseService
|
|
def call(status, tags = [])
|
|
tags = status.text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
|
|
|
|
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |tag|
|
|
status.tags << Tag.where(name: tag).first_or_initialize(name: tag)
|
|
end
|
|
|
|
status.update(sensitive: true) if tags.include?('nsfw')
|
|
end
|
|
end
|