This repository has been archived on 2024-07-22. You can view files and clone it, but cannot push or open issues or pull requests.
mastodon/app/serializers/nodeinfo/serializer.rb

42 lines
753 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class NodeInfo::Serializer < ActiveModel::Serializer
include RoutingHelper
attributes :version, :software, :protocols, :usage
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
private
def instance_presenter
@instance_presenter ||= InstancePresenter.new
end
end