about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-12-12 11:10:11 -0600
committermultiple creatures <dev@multiple-creature.party>2019-12-12 11:10:11 -0600
commit16332682931d3a59c180ecff94e07d6bf650e5e0 (patch)
tree151788b9589179ead99e1bf1e86ae0dbe515c7e3 /app/lib
parent5cf03910f7c40d4683dc6c10dcab9294df566f09 (diff)
avoid posting when body only has mentions it
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/bangtags.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 1284b47e0..201ed9622 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -1001,7 +1001,7 @@ class Bangtags
     text.strip!
     text = text.split("\n").map { |chunk| chunk.strip }.join("\n") if @strip_lines
 
-    if text.blank?
+    if text.blank? || has_only_mentions?(text)
       RemoveStatusService.new.call(@status)
     else
       status.text = text
@@ -1090,6 +1090,10 @@ class Bangtags
     end
   end
 
+  def has_only_mentions?(text)
+    text.match?(/^(?:\s*@((#{Account::USERNAME_RE})(?:@[a-z0-9\.\-]+[a-z0-9]+)?))+$/i)
+  end
+
   def add_tags(to_status, *tags)
     valid_name = /^[[:word:]:._\-]*[[:alpha:]:._·\-][[:word:]:._\-]*$/
     tags = tags.select {|t| t.present? && valid_name.match?(t)}.uniq