From 3e8b4752a1e8d82fd2c5212af6edadb6b1543736 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?KMY=EF=BC=88=E9=9B=AA=E3=81=82=E3=81=99=E3=81=8B=EF=BC=89?= Date: Mon, 11 Dec 2023 14:13:33 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20DistributionWorker=E3=81=A7String=20to?= =?UTF-8?q?=20Integer=E3=81=AE=E3=82=A8=E3=83=A9=E3=83=BC=E3=81=8C?= =?UTF-8?q?=E5=87=BA=E3=82=8B=E5=95=8F=E9=A1=8C=20(#344)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix: DeliveryWorkerでString to Integerのエラーが出る問題 * Test: Mastodon v3向け --- app/models/instance_info.rb | 1 + spec/models/status_spec.rb | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) 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