闭社主体 forked from https://github.com/tootsuite/mastodon
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.

41 lines
753 B

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