Merge remote-tracking branch 'parent/main' into upstream-20231107
This commit is contained in:
commit
64578feeb4
69 changed files with 437 additions and 218 deletions
11
app/serializers/node_info/discovery_serializer.rb
Normal file
11
app/serializers/node_info/discovery_serializer.rb
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NodeInfo::DiscoverySerializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
|
||||
attribute :links
|
||||
|
||||
def links
|
||||
[{ rel: 'http://nodeinfo.diaspora.software/ns/schema/2.0', href: nodeinfo_schema_url }]
|
||||
end
|
||||
end
|
52
app/serializers/node_info/serializer.rb
Normal file
52
app/serializers/node_info/serializer.rb
Normal file
|
@ -0,0 +1,52 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class NodeInfo::Serializer < ActiveModel::Serializer
|
||||
include RoutingHelper
|
||||
include KmyblueCapabilitiesHelper
|
||||
|
||||
attributes :version, :software, :protocols, :services, :usage, :open_registrations, :metadata
|
||||
|
||||
def version
|
||||
'2.0'
|
||||
end
|
||||
|
||||
def software
|
||||
{ name: 'mastodon', version: Mastodon::Version.to_s }
|
||||
end
|
||||
|
||||
def services
|
||||
{ outbound: [], inbound: [] }
|
||||
end
|
||||
|
||||
def protocols
|
||||
%w(activitypub)
|
||||
end
|
||||
|
||||
def usage
|
||||
{
|
||||
users: {
|
||||
total: instance_presenter.user_count,
|
||||
active_month: instance_presenter.active_user_count(4),
|
||||
active_halfyear: instance_presenter.active_user_count(24),
|
||||
},
|
||||
|
||||
local_posts: instance_presenter.status_count,
|
||||
}
|
||||
end
|
||||
|
||||
def open_registrations
|
||||
Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
|
||||
end
|
||||
|
||||
def metadata
|
||||
{
|
||||
features: capabilities_for_nodeinfo,
|
||||
}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def instance_presenter
|
||||
@instance_presenter ||= InstancePresenter.new
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue