diaspora/app/serializers/export/user_serializer.rb
cmrd Senya 7374661e2f
Update the user data export archive format.
This commit introduces changes to the user data export archive format.
This extends data set which is included in the archive. This data can be
then imported to other pods when this feature is implemented.

Also the commit adds the archive format json schema. ATM it is used in
automatic tests only, but in future it will also be used to validate
incoming archives.
2017-08-10 09:36:26 +03:00

49 lines
1.3 KiB
Ruby

module Export
class UserSerializer < ActiveModel::Serializer
attributes :username,
:email,
:language,
:private_key,
:disable_mail,
:show_community_spotlight_in_stream,
:auto_follow_back,
:auto_follow_back_aspect,
:strip_exif
has_one :profile, serializer: FederationEntitySerializer
has_many :contact_groups, each_serializer: Export::AspectSerializer
has_many :contacts, each_serializer: Export::ContactSerializer
has_many :posts, each_serializer: Export::OwnPostSerializer
has_many :followed_tags
has_many :post_subscriptions
has_many :relayables, each_serializer: Export::OwnRelayablesSerializer
private
def relayables
[*comments, *likes, *poll_participations]
end
%i[comments likes poll_participations].each {|collection|
delegate collection, to: :person
}
delegate :person, to: :object
def contact_groups
object.aspects
end
def private_key
object.serialized_private_key
end
def followed_tags
object.followed_tags.map(&:name)
end
def post_subscriptions
Post.subscribed_by(object).pluck(:guid)
end
end
end