about summary refs log tree commit diff
path: root/app/services
diff options
context:
space:
mode:
authorR Tucker <github@ryantucker.us>2017-05-09 22:47:25 -0400
committerEugen Rochko <eugen@zeonfederated.com>2017-05-10 04:47:25 +0200
commite2491680e696d2c285a798ec4c66b26d2748df66 (patch)
tree1c5438c06d4917b7c2e49fa64dc5e8bbf696496b /app/services
parent3a38322a54f0eeb3eba037a4fd61a072bda44311 (diff)
Handle hashtags in spoiler_texts (partial fix for #699) (#2683)
* 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
Diffstat (limited to 'app/services')
-rw-r--r--app/services/process_hashtags_service.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/services/process_hashtags_service.rb b/app/services/process_hashtags_service.rb
index 617a38159..eab033d50 100644
--- a/app/services/process_hashtags_service.rb
+++ b/app/services/process_hashtags_service.rb
@@ -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)