* services: scan spoiler_text for hashtags (#699) * views: link hashtags from spoiler_texts This covers linking hashtags from within the spoiler text on the server-generated pages. * services: fix string concat going into hashtag RE Cleaner Ruby syntax, may handle immutable strings better
This commit is contained in:
parent
3a38322a54
commit
e2491680e6
4 changed files with 15 additions and 3 deletions
|
@ -2,7 +2,8 @@
|
|||
|
||||
class ProcessHashtagsService < BaseService
|
||||
def call(status, tags = [])
|
||||
tags = status.text.scan(Tag::HASHTAG_RE).map(&:first) if status.local?
|
||||
text = [status.text, status.spoiler_text].reject(&:empty?).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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue