闭社主体 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.

44 lines
793 B

  1. # frozen_string_literal: true
  2. class REST::InstanceSerializer < ActiveModel::Serializer
  3. attributes :uri, :title, :description, :email,
  4. :version, :urls, :stats
  5. def uri
  6. Rails.configuration.x.local_domain
  7. end
  8. def title
  9. Setting.site_title
  10. end
  11. def description
  12. Setting.site_description
  13. end
  14. def email
  15. Setting.site_contact_email
  16. end
  17. def version
  18. Mastodon::Version.to_s
  19. end
  20. def stats
  21. {
  22. user_count: instance_presenter.user_count,
  23. status_count: instance_presenter.status_count,
  24. domain_count: instance_presenter.domain_count,
  25. }
  26. end
  27. def urls
  28. { streaming_api: Rails.configuration.x.streaming_api_base_url }
  29. end
  30. private
  31. def instance_presenter
  32. @instance_presenter ||= InstancePresenter.new
  33. end
  34. end