about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-05-06 03:46:15 -0500
committermultiple creatures <dev@multiple-creature.party>2019-05-21 03:16:22 -0500
commit46522d8c1bfdd4c0d7eae708b0e31dd37848f097 (patch)
tree586aed7bdd50346e7caf1e3e07224327cfda724c /app
parent3e8690f2c07cc433c37bbc66d07d1bd43225ee13 (diff)
Do not process mentions or bangtags in drafts. Add `draft?` method to `Status` model.
Diffstat (limited to 'app')
-rw-r--r--app/lib/bangtags.rb4
-rw-r--r--app/models/status.rb4
-rw-r--r--app/services/process_mentions_service.rb2
3 files changed, 7 insertions, 3 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index d18141e71..9bcea41df 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -41,7 +41,7 @@ class Bangtags
     status.text.gsub!('#!!', "#\u200c!")
 
     status.text.split(/(#!(?:.*:!#|{.*?}|[^\s#]+))/).each do |chunk|
-      if @vore_stack.last == '_draft'
+      if @vore_stack.last == '_draft' || (@chunks.present? && @chunks.first.include?('#!draft'))
         @chunks << chunk
       elsif chunk.starts_with?("#!")
         chunk.sub!(/(\\:)?+:+?!#\Z/, '\1')
@@ -396,7 +396,7 @@ class Bangtags
           end
         when 'draft'
           chunk = nil
-          @chunks.insert(0, "[center]`#!draft!#`[/center]\n") unless @chunks.first.include?('#!draft')
+          @chunks.insert(0, "[center]`#!draft!#`[/center]\n") unless @chunks.present? && @chunks.first.include?('#!draft')
           status.visibility = :direct
           @vore_stack.push('_draft')
           @component_stack.push(:var)
diff --git a/app/models/status.rb b/app/models/status.rb
index 0b3d3cb26..1141d3f4f 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -211,6 +211,10 @@ class Status < ApplicationRecord
     proper.text
   end
 
+  def draft?
+    local? && text.present? && text.include?('#!draft')
+  end
+
   def target
     reblog
   end
diff --git a/app/services/process_mentions_service.rb b/app/services/process_mentions_service.rb
index 989cc19a6..0d5f44a53 100644
--- a/app/services/process_mentions_service.rb
+++ b/app/services/process_mentions_service.rb
@@ -8,7 +8,7 @@ class ProcessMentionsService < BaseService
   # remote users
   # @param [Status] status
   def call(status)
-    return unless status.local?
+    return unless status.local? && !status.draft?
 
     @status  = status
     mentions = []