diff --git a/app/models/instance_info.rb b/app/models/instance_info.rb index 79c70fe06f1393..62da02a743fb3b 100644 --- a/app/models/instance_info.rb +++ b/app/models/instance_info.rb @@ -40,6 +40,7 @@ def self.fetch_emoji_reaction_available(domain) return false if info.nil? return true if EMOJI_REACTION_AVAILABLE_SOFTWARES.include?(info['software']) + return false if info.data['metadata'].nil? || !info.data['metadata'].is_a?(Hash) features = info.data.dig('metadata', 'features') return false if features.nil? || !features.is_a?(Array) diff --git a/spec/models/status_spec.rb b/spec/models/status_spec.rb index 5036777c8249b6..ba8b370d721fa0 100644 --- a/spec/models/status_spec.rb +++ b/spec/models/status_spec.rb @@ -463,7 +463,7 @@ describe '.emoji_reaction_availables_map' do subject { described_class.emoji_reaction_availables_map(domains) } - let(:domains) { %w(features_available.com features_unavailable.com features_invalid.com features_nil.com no_info.com mastodon.com misskey.com) } + let(:domains) { %w(features_available.com features_unavailable.com features_invalid.com features_nil.com no_info.com mastodon.com misskey.com old_mastodon.com) } before do Fabricate(:instance_info, domain: 'features_available.com', software: 'mastodon', data: { metadata: { features: ['emoji_reaction'] } }) @@ -472,6 +472,7 @@ Fabricate(:instance_info, domain: 'features_nil.com', software: 'mastodon', data: { metadata: { features: nil } }) Fabricate(:instance_info, domain: 'mastodon.com', software: 'mastodon') Fabricate(:instance_info, domain: 'misskey.com', software: 'misskey') + Fabricate(:instance_info, domain: 'old_mastodon.com', software: 'mastodon', data: { metadata: [] }) end it 'availables if features contains emoji_reaction' do @@ -497,6 +498,10 @@ it 'availables if misskey server' do expect(subject['misskey.com']).to be true end + + it 'unavailables if old mastodon server' do + expect(subject['old_mastodon.com']).to be false + end end describe '.tagged_with' do