1 # frozen_string_literal: true
3 class InitialStateSerializer
< ActiveModel
::Serializer
4 attributes
:meta, :compose, :accounts,
5 :media_attachments, :settings
7 has_one
:push_subscription, serializer
: REST
::WebPushSubscriptionSerializer
11 streaming_api_base_url
: Rails
.configuration
.x
.streaming_api_base_url
,
12 access_token
: object
.token
,
14 domain
: Rails
.configuration
.x
.local_domain
,
15 admin
: object
.admin
&.id
&.to_s
,
16 search_enabled
: Chewy
.enabled
?,
17 version: Mastodon
::Version.to_s
,
18 invites_enabled
: Setting
.min_invite_role
== 'user',
19 mascot
: instance_presenter
.mascot
&.file
&.url
,
20 profile_directory
: Setting
.profile_directory
,
23 if object
.current_account
24 store
[:me] = object
.current_account
.id
.to_s
25 store
[:unfollow_modal] = object
.current_account
.user
.setting_unfollow_modal
26 store
[:boost_modal] = object
.current_account
.user
.setting_boost_modal
27 store
[:delete_modal] = object
.current_account
.user
.setting_delete_modal
28 store
[:auto_play_gif] = object
.current_account
.user
.setting_auto_play_gif
29 store
[:display_media] = object
.current_account
.user
.setting_display_media
30 store
[:expand_spoilers] = object
.current_account
.user
.setting_expand_spoilers
31 store
[:reduce_motion] = object
.current_account
.user
.setting_reduce_motion
32 store
[:is_staff] = object
.current_account
.user
.staff
?
41 if object
.current_account
42 store
[:me] = object
.current_account
.id
.to_s
43 store
[:default_privacy] = object
.current_account
.user
.setting_default_privacy
44 store
[:default_sensitive] = object
.current_account
.user
.setting_default_sensitive
47 store
[:text] = object
.text
if object
.text
54 store
[object
.current_account
.id
.to_s
] = ActiveModelSerializers
::SerializableResource.new(object
.current_account
, serializer
: REST
::AccountSerializer) if object
.current_account
55 store
[object
.admin
.id
.to_s
] = ActiveModelSerializers
::SerializableResource.new(object
.admin
, serializer
: REST
::AccountSerializer) if object
.admin
60 { accept_content_types
: MediaAttachment
::IMAGE_FILE_EXTENSIONS + MediaAttachment
::VIDEO_FILE_EXTENSIONS + MediaAttachment
::IMAGE_MIME_TYPES + MediaAttachment
::VIDEO_MIME_TYPES }
65 def instance_presenter
66 @instance_presenter ||= InstancePresenter
.new