mirror of
https://github.com/mastodon/mastodon.git
synced 2025-01-24 02:51:43 +01:00
fix: custom emoji shortcode case not respected
This commit is contained in:
parent
27e79da6b9
commit
07e6df0d40
@ -19,22 +19,28 @@ class EntityCache
|
|||||||
shortcodes = Array(shortcodes)
|
shortcodes = Array(shortcodes)
|
||||||
return [] if shortcodes.empty?
|
return [] if shortcodes.empty?
|
||||||
|
|
||||||
cached = Rails.cache.read_multi(*shortcodes.map { |shortcode| to_key(:emoji, shortcode, domain) })
|
domain = domain.downcase if domain
|
||||||
|
|
||||||
|
cached = Rails.cache.read_multi(*shortcodes.map { |shortcode| to_emoji(:emoji, shortcode, domain) })
|
||||||
uncached_ids = []
|
uncached_ids = []
|
||||||
|
|
||||||
shortcodes.each do |shortcode|
|
shortcodes.each do |shortcode|
|
||||||
uncached_ids << shortcode unless cached.key?(to_key(:emoji, shortcode, domain))
|
uncached_ids << shortcode unless cached.key?(to_emoji(:emoji, shortcode, domain))
|
||||||
end
|
end
|
||||||
|
|
||||||
unless uncached_ids.empty?
|
unless uncached_ids.empty?
|
||||||
uncached = CustomEmoji.enabled.where(shortcode: shortcodes, domain: domain).index_by(&:shortcode)
|
uncached = CustomEmoji.enabled.where(shortcode: shortcodes, domain: domain).index_by(&:shortcode)
|
||||||
uncached.each_value { |item| Rails.cache.write(to_key(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
uncached.each_value { |item| Rails.cache.write(to_emoji(:emoji, item.shortcode, domain), item, expires_in: MAX_EXPIRATION) }
|
||||||
end
|
end
|
||||||
|
|
||||||
shortcodes.filter_map { |shortcode| cached[to_key(:emoji, shortcode, domain)] || uncached[shortcode] }
|
shortcodes.filter_map { |shortcode| cached[to_emoji(:emoji, shortcode, domain)] || uncached[shortcode] }
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_key(type, *ids)
|
def to_key(type, *ids)
|
||||||
"#{type}:#{ids.compact.map(&:downcase).join(':')}"
|
"#{type}:#{ids.compact.map(&:downcase).join(':')}"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def to_emoji(type, *ids)
|
||||||
|
"#{type}:#{ids.compact.join(':')}"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user