From 3caf0ba92313c71d722b30f77c5c1355601fc7c1 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Wed, 27 Sep 2017 04:14:03 +0200 Subject: [PATCH] Fix empty query sent to postgres for custom emojis (#5121) --- app/models/custom_emoji.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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