commit: 3caf0ba92313c71d722b30f77c5c1355601fc7c1
parent: 6e83b5e719cf58a554681859c0b74df626bb66a1
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Wed, 27 Sep 2017 04:14:03 +0200
Fix empty query sent to postgres for custom emojis (#5121)
Diffstat:
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git 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