From 8d9ff90fd1318b63df298c7c8599be8893604ddf Mon Sep 17 00:00:00 2001 From: KMY Date: Thu, 12 Oct 2023 19:37:16 +0900 Subject: [PATCH] =?UTF-8?q?Fix:=20#89=20NodeInfo=E5=90=91=E3=81=91?= =?UTF-8?q?=E3=81=AE=E6=A9=9F=E8=83=BD=E4=B8=80=E8=A6=A7=E8=A1=A8=E3=82=92?= =?UTF-8?q?=E4=BD=9C=E6=88=90=E3=81=97=E3=81=A6=E5=8C=BA=E5=88=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/kmyblue_capabilities_helper.rb | 25 +++++++++++++++++++ app/serializers/nodeinfo/serializer.rb | 2 +- spec/serializers/nodeinfo/serializer_spec.rb | 5 ++++ .../rest/instance_serializer_spec.rb | 4 +++ 4 files changed, 35 insertions(+), 1 deletion(-) diff --git a/app/helpers/kmyblue_capabilities_helper.rb b/app/helpers/kmyblue_capabilities_helper.rb index 8653a3f9daa7a9..455561a597f029 100644 --- a/app/helpers/kmyblue_capabilities_helper.rb +++ b/app/helpers/kmyblue_capabilities_helper.rb @@ -30,4 +30,29 @@ def fedibird_capabilities capabilities end + + def capabilities_for_nodeinfo + capabilities = %i( + wide_emoji + status_reference + quote + kmyblue_quote + searchability + kmyblue_searchability + visibility_mutual + visibility_limited + kmyblue_antenna + kmyblue_bookmark_category + kmyblue_searchability_limited + kmyblue_circle_history + ) + + capabilities << :full_text_search if Chewy.enabled? + if Setting.enable_emoji_reaction + capabilities << :emoji_reaction + capabilities << :enable_wide_emoji_reaction + end + + capabilities + end end diff --git a/app/serializers/nodeinfo/serializer.rb b/app/serializers/nodeinfo/serializer.rb index 3555f0bd8ddc17..83d63bb3971fb6 100644 --- a/app/serializers/nodeinfo/serializer.rb +++ b/app/serializers/nodeinfo/serializer.rb @@ -40,7 +40,7 @@ def open_registrations def metadata { - features: fedibird_capabilities, + features: capabilities_for_nodeinfo, } end diff --git a/spec/serializers/nodeinfo/serializer_spec.rb b/spec/serializers/nodeinfo/serializer_spec.rb index c43b0b569fb6db..8352a44143bb07 100644 --- a/spec/serializers/nodeinfo/serializer_spec.rb +++ b/spec/serializers/nodeinfo/serializer_spec.rb @@ -28,5 +28,10 @@ it 'returns features' do expect(serialization['metadata']['features']).to include 'emoji_reaction' end + + it 'returns nodeinfo own features' do + expect(serialization['metadata']['features']).to include 'quote' + expect(serialization['metadata']['features']).to_not include 'kmyblue_markdown' + end end end diff --git a/spec/serializers/rest/instance_serializer_spec.rb b/spec/serializers/rest/instance_serializer_spec.rb index a9a3259aa87e73..4b33d15daaf31c 100644 --- a/spec/serializers/rest/instance_serializer_spec.rb +++ b/spec/serializers/rest/instance_serializer_spec.rb @@ -22,5 +22,9 @@ it 'returns fedibird_capabilities' do expect(serialization['fedibird_capabilities']).to include 'emoji_reaction' end + + it 'returns api own fedibird_capabilities' do + expect(serialization['fedibird_capabilities']).to include 'kmyblue_markdown' + end end end