2017-07-08 12:51:05 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
class InitialStateSerializer < ActiveModel::Serializer
|
|
|
|
attributes :meta, :compose, :accounts,
|
2017-07-13 20:15:32 +00:00
|
|
|
:media_attachments, :settings, :push_subscription
|
2017-07-08 12:51:05 +00:00
|
|
|
|
|
|
|
def meta
|
2017-07-11 13:27:59 +00:00
|
|
|
store = {
|
2017-07-08 12:51:05 +00:00
|
|
|
streaming_api_base_url: Rails.configuration.x.streaming_api_base_url,
|
|
|
|
access_token: object.token,
|
|
|
|
locale: I18n.locale,
|
|
|
|
domain: Rails.configuration.x.local_domain,
|
|
|
|
admin: object.admin&.id,
|
|
|
|
}
|
2017-07-11 13:27:59 +00:00
|
|
|
|
|
|
|
if object.current_account
|
|
|
|
store[:me] = object.current_account.id
|
2017-07-18 15:14:43 +00:00
|
|
|
store[:unfollow_modal] = object.current_account.user.setting_unfollow_modal
|
2017-07-11 13:27:59 +00:00
|
|
|
store[:boost_modal] = object.current_account.user.setting_boost_modal
|
|
|
|
store[:delete_modal] = object.current_account.user.setting_delete_modal
|
|
|
|
store[:auto_play_gif] = object.current_account.user.setting_auto_play_gif
|
|
|
|
end
|
|
|
|
|
|
|
|
store
|
2017-07-08 12:51:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def compose
|
2017-07-11 13:27:59 +00:00
|
|
|
store = {}
|
|
|
|
|
|
|
|
if object.current_account
|
|
|
|
store[:me] = object.current_account.id
|
|
|
|
store[:default_privacy] = object.current_account.user.setting_default_privacy
|
|
|
|
store[:default_sensitive] = object.current_account.user.setting_default_sensitive
|
|
|
|
end
|
|
|
|
|
2017-08-14 02:53:31 +00:00
|
|
|
store[:text] = object.text if object.text
|
|
|
|
|
2017-07-11 13:27:59 +00:00
|
|
|
store
|
2017-07-08 12:51:05 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def accounts
|
|
|
|
store = {}
|
2017-07-11 13:27:59 +00:00
|
|
|
store[object.current_account.id] = ActiveModelSerializers::SerializableResource.new(object.current_account, serializer: REST::AccountSerializer) if object.current_account
|
|
|
|
store[object.admin.id] = ActiveModelSerializers::SerializableResource.new(object.admin, serializer: REST::AccountSerializer) if object.admin
|
2017-07-08 12:51:05 +00:00
|
|
|
store
|
|
|
|
end
|
|
|
|
|
|
|
|
def media_attachments
|
|
|
|
{ accept_content_types: MediaAttachment::IMAGE_MIME_TYPES + MediaAttachment::VIDEO_MIME_TYPES }
|
|
|
|
end
|
|
|
|
end
|