From 2aae6cfdbe63a2c391527d2ab338824172c3e64b Mon Sep 17 00:00:00 2001 From: Joffrey JAFFEUX Date: Mon, 5 Jun 2017 18:53:11 +0200 Subject: [PATCH] look for aliases in Emoji.lookup_unicode --- app/models/emoji.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/models/emoji.rb b/app/models/emoji.rb index 44037f96abc..80c66b26ac2 100644 --- a/app/models/emoji.rb +++ b/app/models/emoji.rb @@ -144,11 +144,20 @@ class Emoji def self.lookup_unicode(name) @reverse_map ||= begin map = {} + db['emojis'].each do |e| next if e['name'] == 'tm' code = replacement_code(e['code']) map[e['name']] = code if code end + + Emoji.aliases.each do |key, alias_names| + next unless alias_code = map[key] + alias_names.each do |alias_name| + map[alias_name] = alias_code + end + end + map end @reverse_map[name]