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.

54 lines
1015 B

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