logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

initial_state_serializer.rb (2135B)


  1. # frozen_string_literal: true
  2. class InitialStateSerializer < ActiveModel::Serializer
  3. attributes :meta, :compose, :accounts,
  4. :media_attachments, :settings, :push_subscription
  5. def meta
  6. store = {
  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. admin: object.admin&.id&.to_s,
  12. search_enabled: Chewy.enabled?,
  13. }
  14. if object.current_account
  15. store[:me] = object.current_account.id.to_s
  16. store[:unfollow_modal] = object.current_account.user.setting_unfollow_modal
  17. store[:boost_modal] = object.current_account.user.setting_boost_modal
  18. store[:delete_modal] = object.current_account.user.setting_delete_modal
  19. store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif
  20. store[:display_sensitive_media] = object.current_account.user.setting_display_sensitive_media
  21. store[:reduce_motion] = object.current_account.user.setting_reduce_motion
  22. end
  23. store
  24. end
  25. def compose
  26. store = {}
  27. if object.current_account
  28. store[:me] = object.current_account.id.to_s
  29. store[:default_privacy] = object.current_account.user.setting_default_privacy
  30. store[:default_sensitive] = object.current_account.user.setting_default_sensitive
  31. end
  32. store[:text] = object.text if object.text
  33. store
  34. end
  35. def accounts
  36. store = {}
  37. store[object.current_account.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) if object.current_account
  38. store[object.admin.id.to_s] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) if object.admin
  39. store
  40. end
  41. def media_attachments
  42. { accept_content_types: MediaAttachment::IMAGE_FILE_EXTENSIONS + MediaAttachment::VIDEO_FILE_EXTENSIONS + MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES }
  43. end
  44. end