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.

39 lines
1.3 KiB

  1. # frozen_string_literal: true
  2. class InitialStateSerializer < ActiveModel::Serializer
  3. attributes :meta, :compose, :accounts,
  4. :media_attachments, :settings
  5. def meta
  6. {
  7. streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
  8. access_token: object.token,
  9. locale: I18n.locale,
  10. domain: Rails.configuration.x.local_domain,
  11. me: object.current_account.id,
  12. admin: object.admin&.id,
  13. boost_modal: object.current_account.user.setting_boost_modal,
  14. delete_modal: object.current_account.user.setting_delete_modal,
  15. auto_play_gif: object.current_account.user.setting_auto_play_gif,
  16. system_font_ui: object.current_account.user.setting_system_font_ui,
  17. }
  18. end
  19. def compose
  20. {
  21. me: object.current_account.id,
  22. default_privacy: object.current_account.user.setting_default_privacy,
  23. }
  24. end
  25. def accounts
  26. store = {}
  27. store[object.current_account.id] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer)
  28. store[object.admin.id] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) unless object.admin.nil?
  29. store
  30. end
  31. def media_attachments
  32. { accept_content_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES }
  33. end
  34. end