about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2017-09-27 04:14:03 +0200
committerGitHub <noreply@github.com>2017-09-27 04:14:03 +0200
commit3caf0ba92313c71d722b30f77c5c1355601fc7c1 (patch)
tree1dc3924c28cf303b88a029d3cf3ab7790f78ecea
parent6e83b5e719cf58a554681859c0b74df626bb66a1 (diff)
Fix empty query sent to postgres for custom emojis (#5121)
-rw-r--r--app/models/custom_emoji.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/app/models/custom_emoji.rb b/app/models/custom_emoji.rb
index aff9f8dfa..e80c58155 100644
--- a/app/models/custom_emoji.rb
+++ b/app/models/custom_emoji.rb
@@ -33,7 +33,11 @@ class CustomEmoji < ApplicationRecord
   class << self
     def from_text(text, domain)
       return [] if text.blank?
-      shortcodes = text.scan(SCAN_RE).map(&:first)
+
+      shortcodes = text.scan(SCAN_RE).map(&:first).uniq
+
+      return [] if shortcodes.empty?
+
       where(shortcode: shortcodes, domain: domain)
     end
   end