You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
890 B

  1. # frozen_string_literal: true
  2. class NodeInfo::Serializer < ActiveModel::Serializer
  3. include RoutingHelper
  4. attributes :version, :software, :protocols, :usage, :open_registrations
  5. def version
  6. '2.0'
  7. end
  8. def software
  9. { name: 'mastodon', version: Mastodon::Version.to_s }
  10. end
  11. def services
  12. { outbound: [], inbound: [] }
  13. end
  14. def protocols
  15. %w(activitypub)
  16. end
  17. def usage
  18. {
  19. users: {
  20. total: instance_presenter.user_count,
  21. active_month: instance_presenter.active_user_count(4),
  22. active_halfyear: instance_presenter.active_user_count(24),
  23. },
  24. local_posts: instance_presenter.status_count,
  25. }
  26. end
  27. def open_registrations
  28. Setting.registrations_mode != 'none' && !Rails.configuration.x.single_user_mode
  29. end
  30. private
  31. def instance_presenter
  32. @instance_presenter ||= InstancePresenter.new
  33. end
  34. end