about summary refs log tree commit diff
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-08-04 00:26:33 -0500
committermultiple creatures <dev@multiple-creature.party>2019-08-04 00:26:33 -0500
commitf46293f6d9420840749dc7db0c422d7a2b1ed28e (patch)
tree4ecb71de037e92fa2b7f6571800759e5ba5b7e5c
parent2be5c8a55c06505ea70159a5ab61e6f568f631f0 (diff)
limit inferred reject replies trigger to the start of first/last line; simplify text before matching
-rw-r--r--app/models/status.rb9
1 files changed, 5 insertions, 4 deletions
diff --git a/app/models/status.rb b/app/models/status.rb
index f2b40c516..a6be93789 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -47,7 +47,8 @@ class Status < ApplicationRecord
 
   # match both with and without U+FE0F (the emoji variation selector)
   LOCAL_ONLY_TOKENS = /(?:#!|\u{1f441}\ufe0f?)\u200b?\z/
-  REJECT_REPLIES_TOKENS = /\b(?:ms_dont_at_me|no (?:replie|mention)s|(?:don't|do not) (?:@|at|reply|mention)(?: (?:me|us))?)\b/i
+  REJECT_REPLIES_TOKENS = /^(?:please )?(?:ms_dont_at_me|no (?:replie|mention)s|(?:dont|do not) (?:@|at|reply|mention)(?: (?:me|us))?)\b/i
+  SIMPLIFIED = /[^\w\s@_\"\'\-]+/
 
   # If `override_timestamps` is set at creation time, Snowflake ID creation
   # will be based on current time instead of `created_at`
@@ -549,9 +550,9 @@ class Status < ApplicationRecord
 
   def marked_reject_replies?
     return true if reject_replies
-    return true if spoiler_text.present? && REJECT_REPLIES_TOKENS.match?(spoiler_text)
-    return true if content.present? && REJECT_REPLIES_TOKENS.match?(content.lines.first)
-    content.present? && REJECT_REPLIES_TOKENS.match?(content.lines.last)
+    return true if spoiler_text.present? && REJECT_REPLIES_TOKENS.match?(spoiler_text.gsub(SIMPLIFIED, '').strip)
+    return true if content.present? && REJECT_REPLIES_TOKENS.match?(content.lines.first.gsub(SIMPLIFIED, '').strip)
+    content.present? && REJECT_REPLIES_TOKENS.match?(content.lines.last.gsub(SIMPLIFIED, '').strip)
   end
 
   private