From f46293f6d9420840749dc7db0c422d7a2b1ed28e Mon Sep 17 00:00:00 2001 From: multiple creatures Date: Sun, 4 Aug 2019 00:26:33 -0500 Subject: [PATCH] limit inferred reject replies trigger to the start of first/last line; simplify text before matching --- app/models/status.rb | 9 +++++---- 1 file 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