2019-09-29 21:31:51 +02:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class NodeInfo::Serializer < ActiveModel::Serializer
|
|
|
|
include RoutingHelper
|
|
|
|
|
2022-06-01 16:24:07 +02:00
|
|
|
attributes :version, :software, :protocols, :services, :usage, :open_registrations, :metadata
|
2019-09-29 21:31:51 +02:00
|
|
|
|
|
|
|
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
|
|
|
|
|
2019-10-02 21:02:48 +02:00
|
|
|
def open_registrations
|
|
|
|
Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
|
|
|
|
end
|
|
|
|
|
2022-06-01 16:24:07 +02:00
|
|
|
def metadata
|
2023-11-28 01:51:22 +01:00
|
|
|
{
|
|
|
|
nodeName: Setting.site_title,
|
|
|
|
nodeDescription: Setting.site_short_description,
|
|
|
|
}
|
2022-06-01 16:24:07 +02:00
|
|
|
end
|
|
|
|
|
2019-09-29 21:31:51 +02:00
|
|
|
private
|
|
|
|
|
|
|
|
def instance_presenter
|
|
|
|
@instance_presenter ||= InstancePresenter.new
|
|
|
|
end
|
|
|
|
end
|