mastodon/app/services/process_hashtags_service.rb
Eugen Rochko 72698bc3b4 Fix regressions from #2683 (#2970)
* Fix regressions from #2683

Properly format spoiler text HTML, while keeping old logic for blankness intact
Process hashtags and mentions in spoiler text
Format spoiler text for Atom
Change "show more" toggle into a button instead of anchor
Fix style regression on dropdowns for detailed statuses

* Fix lint issue

* Convert spoiler text to plaintext in desktop notifications
2017-05-11 00:28:10 +02:00

15 lines
470 B
Ruby

# frozen_string_literal: true
class ProcessHashtagsService < BaseService
def call(status, tags = [])
text = [status.text, status.spoiler_text].reject(&:blank?).join(' ')
tags = 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