mirror of https://github.com/mastodon/mastodon
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
941 B
Ruby
50 lines
941 B
Ruby
5 years ago
|
# frozen_string_literal: true
|
||
|
|
||
|
class NodeInfo::Serializer < ActiveModel::Serializer
|
||
|
include RoutingHelper
|
||
|
|
||
3 years ago
|
attributes :version, :software, :protocols, :services, :usage, :open_registrations, :metadata
|
||
5 years ago
|
|
||
|
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
|
||
|
|
||
5 years ago
|
def open_registrations
|
||
|
Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
|
||
|
end
|
||
|
|
||
3 years ago
|
def metadata
|
||
2 years ago
|
{}
|
||
3 years ago
|
end
|
||
|
|
||
5 years ago
|
private
|
||
|
|
||
|
def instance_presenter
|
||
|
@instance_presenter ||= InstancePresenter.new
|
||
|
end
|
||
|
end
|