Merge commit '86244599d3
' into kb-draft-5.3-lts
This commit is contained in:
commit
e578a4eaca
6 changed files with 75 additions and 51 deletions
31
app/helpers/kmyblue_capabilities_helper.rb
Normal file
31
app/helpers/kmyblue_capabilities_helper.rb
Normal file
|
@ -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,
|
||||
:kmyblue_visibility_public_unlisted,
|
||||
]
|
||||
|
||||
capabilities << :profile_search unless Chewy.enabled?
|
||||
if Setting.enable_emoji_reaction
|
||||
capabilities << :emoji_reaction
|
||||
capabilities << :enable_wide_emoji_reaction
|
||||
end
|
||||
|
||||
capabilities
|
||||
end
|
||||
end
|
|
@ -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 @@ class NodeInfo::Serializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
def metadata
|
||||
{}
|
||||
{
|
||||
features: fedibird_capabilities,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
@ -8,6 +8,7 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
end
|
||||
|
||||
include RoutingHelper
|
||||
include KmyblueCapabilitiesHelper
|
||||
|
||||
attributes :domain, :title, :version, :source_url, :description,
|
||||
:usage, :thumbnail, :languages, :configuration,
|
||||
|
@ -105,31 +106,6 @@ class REST::InstanceSerializer < ActiveModel::Serializer
|
|||
}
|
||||
end
|
||||
|
||||
# for third party apps
|
||||
def fedibird_capabilities
|
||||
capabilities = [
|
||||
:kmyblue_visibility_public_unlisted,
|
||||
: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
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def registrations_enabled?
|
||||
|
|
|
@ -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 @@ class REST::V1::InstanceSerializer < ActiveModel::Serializer
|
|||
UserRole.everyone.can?(:invite_users)
|
||||
end
|
||||
|
||||
# for third party apps
|
||||
def fedibird_capabilities
|
||||
capabilities = [
|
||||
:kmyblue_visibility_public_unlisted,
|
||||
: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
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def instance_presenter
|
||||
|
|
32
spec/serializers/nodeinfo/serializer_spec.rb
Normal file
32
spec/serializers/nodeinfo/serializer_spec.rb
Normal file
|
@ -0,0 +1,32 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
describe NodeInfo::Serializer do # rubocop:disable RSpec/FilePath
|
||||
let(:serialization) do
|
||||
JSON.parse(
|
||||
ActiveModelSerializers::SerializableResource.new(
|
||||
record, adapter: NodeInfo::Adapter, serializer: described_class, root: 'nodeinfo'
|
||||
).to_json
|
||||
)
|
||||
end
|
||||
let(:record) { {} }
|
||||
|
||||
describe 'nodeinfo version' do
|
||||
it 'returns 2.0' do
|
||||
expect(serialization['version']).to eq '2.0'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'mastodon version' do
|
||||
it 'contains kmyblue' do
|
||||
expect(serialization['software']['version'].include?('kmyblue')).to be true
|
||||
end
|
||||
end
|
||||
|
||||
describe 'metadata' do
|
||||
it 'returns features' do
|
||||
expect(serialization['metadata']['features']).to include 'emoji_reaction'
|
||||
end
|
||||
end
|
||||
end
|
|
@ -17,4 +17,10 @@ describe REST::InstanceSerializer do
|
|||
expect(serialization['usage']).to eq({ 'users' => { 'active_month' => 0 } })
|
||||
end
|
||||
end
|
||||
|
||||
describe 'fedibird_capabilities' do
|
||||
it 'returns fedibird_capabilities' do
|
||||
expect(serialization['fedibird_capabilities']).to include 'emoji_reaction'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue