From 016a8490d2cabd499c295b1405a607a036670d0d Mon Sep 17 00:00:00 2001 From: KMY Date: Fri, 6 Oct 2023 18:59:10 +0900 Subject: [PATCH] =?UTF-8?q?#63=20NodeInfo=E3=81=A7=E3=81=AE`fedibird=5Fcap?= =?UTF-8?q?abilities`=E5=85=AC=E9=96=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/helpers/kmyblue_capabilities_helper.rb | 31 +++++++++++++++++++ app/serializers/nodeinfo/serializer.rb | 5 ++- app/serializers/rest/instance_serializer.rb | 26 +--------------- .../rest/v1/instance_serializer.rb | 26 +--------------- 4 files changed, 37 insertions(+), 51 deletions(-) create mode 100644 app/helpers/kmyblue_capabilities_helper.rb diff --git a/app/helpers/kmyblue_capabilities_helper.rb b/app/helpers/kmyblue_capabilities_helper.rb new file mode 100644 index 00000000000000..7ad1d55fc4dd53 --- /dev/null +++ b/app/helpers/kmyblue_capabilities_helper.rb @@ -0,0 +1,31 @@ +# frozen_string_literal: true + +module KmyblueCapabilitiesHelper + def fedibird_capabilities + capabilities = [ + :enable_wide_emoji, + :kmyblue_searchability, + :searchability, + :kmyblue_markdown, + :kmyblue_reaction_deck, + :kmyblue_visibility_login, + :status_reference, + :visibility_mutual, + :visibility_limited, + :kmyblue_limited_scope, + :kmyblue_antenna, + :kmyblue_bookmark_category, + :kmyblue_quote, + :kmyblue_searchability_limited, + ] + + capabilities << :profile_search unless Chewy.enabled? + if Setting.enable_emoji_reaction + capabilities << :emoji_reaction + capabilities << :enable_wide_emoji_reaction + end + capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility + + capabilities + end +end diff --git a/app/serializers/nodeinfo/serializer.rb b/app/serializers/nodeinfo/serializer.rb index f70cc38f0697f8..df8bc07611522a 100644 --- a/app/serializers/nodeinfo/serializer.rb +++ b/app/serializers/nodeinfo/serializer.rb @@ -2,6 +2,7 @@ class NodeInfo::Serializer < ActiveModel::Serializer include RoutingHelper + include KmyblueCapabilitiesHelper attributes :version, :software, :protocols, :services, :usage, :open_registrations, :metadata @@ -38,7 +39,9 @@ def open_registrations end def metadata - {} + { + fedibird_capabilities: fedibird_capabilities, + } end private diff --git a/app/serializers/rest/instance_serializer.rb b/app/serializers/rest/instance_serializer.rb index 9b52277bf04d1b..ed4e40523aa42b 100644 --- a/app/serializers/rest/instance_serializer.rb +++ b/app/serializers/rest/instance_serializer.rb @@ -8,6 +8,7 @@ class ContactSerializer < ActiveModel::Serializer end include RoutingHelper + include KmyblueCapabilitiesHelper attributes :domain, :title, :version, :source_url, :description, :usage, :thumbnail, :languages, :configuration, @@ -105,31 +106,6 @@ def registrations } end - # for third party apps - def fedibird_capabilities - capabilities = [ - :enable_wide_emoji, - :enable_wide_emoji_reaction, - :kmyblue_searchability, - :searchability, - :kmyblue_markdown, - :kmyblue_reaction_deck, - :kmyblue_visibility_login, - :status_reference, - :visibility_mutual, - :visibility_limited, - :kmyblue_limited_scope, - :kmyblue_antenna, - :kmyblue_bookmark_category, - ] - - capabilities << :profile_search unless Chewy.enabled? - capabilities << :emoji_reaction if Setting.enable_emoji_reaction - capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility - - capabilities - end - private def registrations_enabled? diff --git a/app/serializers/rest/v1/instance_serializer.rb b/app/serializers/rest/v1/instance_serializer.rb index 64951b3db5293d..d0473f5f97ca1c 100644 --- a/app/serializers/rest/v1/instance_serializer.rb +++ b/app/serializers/rest/v1/instance_serializer.rb @@ -2,6 +2,7 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer include RoutingHelper + include KmyblueCapabilitiesHelper attributes :uri, :title, :short_description, :description, :email, :version, :urls, :stats, :thumbnail, @@ -114,31 +115,6 @@ def invites_enabled UserRole.everyone.can?(:invite_users) end - # for third party apps - def fedibird_capabilities - capabilities = [ - :enable_wide_emoji, - :enable_wide_emoji_reaction, - :kmyblue_searchability, - :searchability, - :kmyblue_markdown, - :kmyblue_reaction_deck, - :kmyblue_visibility_login, - :status_reference, - :visibility_mutual, - :visibility_limited, - :kmyblue_limited_scope, - :kmyblue_antenna, - :kmyblue_bookmark_category, - ] - - capabilities << :profile_search unless Chewy.enabled? - capabilities << :emoji_reaction if Setting.enable_emoji_reaction - capabilities << :kmyblue_visibility_public_unlisted if Setting.enable_public_unlisted_visibility - - capabilities - end - private def instance_presenter