Compare commits

...

4 Commits

Author SHA1 Message Date
HolgerHuo
049bdedcc4
Merge 6eeb9215b6 into 7d2dda97b3 2025-07-16 08:04:43 +00:00
Renaud Chaput
7d2dda97b3
Remove the "to triage" label status (#35394)
Some checks are pending
Check i18n / check-i18n (push) Waiting to run
CodeQL / Analyze (javascript) (push) Waiting to run
CodeQL / Analyze (ruby) (push) Waiting to run
Check formatting / lint (push) Waiting to run
Ruby Testing / build (production) (push) Waiting to run
Ruby Testing / build (test) (push) Waiting to run
Ruby Testing / test (.ruby-version) (push) Blocked by required conditions
Ruby Testing / test (3.2) (push) Blocked by required conditions
Ruby Testing / test (3.3) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (.ruby-version) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.2) (push) Blocked by required conditions
Ruby Testing / ImageMagick tests (3.3) (push) Blocked by required conditions
Ruby Testing / End to End testing (.ruby-version) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.2) (push) Blocked by required conditions
Ruby Testing / End to End testing (3.3) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, docker.elastic.co/elasticsearch/elasticsearch:8.10.2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (.ruby-version, opensearchproject/opensearch:2) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.2, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
Ruby Testing / Elastic Search integration testing (3.3, docker.elastic.co/elasticsearch/elasticsearch:7.17.13) (push) Blocked by required conditions
2025-07-16 07:17:21 +00:00
HolgerHuo
6eeb9215b6
add: entity_cache_spec.rb 2024-11-23 08:47:28 +08:00
Holger Huo
07e6df0d40
fix: custom emoji shortcode case not respected 2024-11-23 08:45:12 +08:00
4 changed files with 19 additions and 6 deletions

View File

@ -1,6 +1,6 @@
name: Bug Report (Web Interface)
description: There is a problem using Mastodon's web interface.
labels: ['status/to triage', 'area/web interface']
labels: ['area/web interface']
type: Bug
body:
- type: markdown

View File

@ -1,7 +1,6 @@
name: Bug Report (server / API)
description: |
There is a problem with the HTTP server, REST API, ActivityPub interaction, etc.
labels: ['status/to triage']
type: 'Bug'
body:
- type: markdown

View File

@ -19,24 +19,30 @@ class EntityCache
shortcodes = Array(shortcodes)
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 = []
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
if uncached_ids.empty?
uncached = {}
else
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
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
def to_key(type, *ids)
"#{type}:#{ids.compact.map(&:downcase).join(':')}"
end
def to_emoji(type, *ids)
"#{type}:#{ids.compact.join(':')}"
end
end

View File

@ -18,4 +18,12 @@ RSpec.describe EntityCache do
end
end
end
describe '#to_emoji' do
context 'when input shortcode has cases' do
it 'returns emoji with cases preserved' do
expect(described_class.instance.to_emoji(:emoji, 'FooBar', 'example.org')).to eq 'emoji:FooBar:example.org'
end
end
end
end