instance_serializer.rb 793 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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