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.
33 lines
957 B
Ruby
33 lines
957 B
Ruby
module Export
|
|
# This is a serializer for the user's own posts
|
|
class OwnPostSerializer < FederationEntitySerializer
|
|
# Only for public posts.
|
|
# Includes URIs of pods which must be notified on the post updates.
|
|
# Must always include local pod URI since we will want all the updates on the post if user migrates.
|
|
has_many :subscribed_pods_uris
|
|
|
|
# Only for private posts.
|
|
# Includes diaspora* IDs of people who must be notified on post updates.
|
|
has_many :subscribed_users_ids
|
|
|
|
# Normally accepts Post as an object.
|
|
def initialize(*)
|
|
super
|
|
self.except = [excluded_subscription_key]
|
|
end
|
|
|
|
private
|
|
|
|
def subscribed_pods_uris
|
|
object.subscribed_pods_uris.push(AppConfig.pod_uri.to_s)
|
|
end
|
|
|
|
def subscribed_users_ids
|
|
object.subscribers.map(&:diaspora_handle)
|
|
end
|
|
|
|
def excluded_subscription_key
|
|
entity.public ? :subscribed_users_ids : :subscribed_pods_uris
|
|
end
|
|
end
|
|
end
|