]> cat aescling's git repositories - mastodon.git/commitdiff
Fix empty query sent to postgres for custom emojis (#5121)
authorEugen Rochko <eugen@zeonfederated.com>
Wed, 27 Sep 2017 02:14:03 +0000 (04:14 +0200)
committerGitHub <noreply@github.com>
Wed, 27 Sep 2017 02:14:03 +0000 (04:14 +0200)
app/models/custom_emoji.rb

index aff9f8dfa3f7770ae4460aaf5598e8d564bba918..e80c581553c8bb665c355b0db00aeaee3c1af27a 100644 (file)
@@ -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