New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update the user data export archive format. #6726
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
7db4f82
Refactor account deletion spec
cmrd-senya fca6121
Exporter::PostsWithActivity class
cmrd-senya c985af1
New Exporter::OthersRelayables class
cmrd-senya c63493b
New Exporter::NonContactAuthors class
cmrd-senya 2c3f116
Add new scopes for the Post model
cmrd-senya 1b1db3b
Bump diaspora_federation
cmrd-senya 7374661
Update the user data export archive format.
cmrd-senya d8398ca
Move misc_spec.rb to spec/spec
cmrd-senya 0a1b434
Add a little cuke test for profile export
cmrd-senya 9bcdc90
Fix Person.in_aspects scope multiple return
cmrd-senya File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
module Export | ||
class OthersDataSerializer < ActiveModel::Serializer | ||
# Relayables of other people in the archive: comments, likes, participations, poll participations where author is | ||
# the archive owner | ||
has_many :relayables, each_serializer: FederationEntitySerializer | ||
|
||
# Parent posts of user's own relayables. We have to save metadata to use | ||
# it in case when posts temporary unavailable on the target pod. | ||
has_many :posts, each_serializer: FederationEntitySerializer | ||
|
||
# Authors of posts where we participated and authors are not in contacts | ||
has_many :non_contact_authors, each_serializer: PersonMetadataSerializer | ||
|
||
private | ||
|
||
def relayables | ||
%i[comments likes poll_participations].map {|relayable| | ||
others_relayables.send(relayable) | ||
}.sum | ||
end | ||
|
||
def others_relayables | ||
@others_relayables ||= Diaspora::Exporter::OthersRelayables.new(object.person_id) | ||
end | ||
|
||
def posts | ||
@posts ||= Diaspora::Exporter::PostsWithActivity.new(object).query | ||
end | ||
|
||
def non_contact_authors | ||
Diaspora::Exporter::NonContactAuthors.new(posts, object).query | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Export | ||
# This is a serializer for the user's own relayables. We remove signature from the own relayables since it isn't | ||
# useful and takes space. | ||
class OwnRelayablesSerializer < FederationEntitySerializer | ||
private | ||
|
||
def modify_serializable_object(hash) | ||
super.tap {|hash| | ||
hash[:entity_data].delete(:author_signature) | ||
} | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Export | ||
class PersonMetadataSerializer < ActiveModel::Serializer | ||
attributes :guid, | ||
:account_id, | ||
:public_key | ||
|
||
private | ||
|
||
def account_id | ||
object.diaspora_handle | ||
end | ||
|
||
def public_key | ||
object.serialized_public_key | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just saw that
subscribers
returns the person multiple times, when you have the person in multiple aspects.That's because Person.in_aspects which is used in User.people_in_aspects returns the person multiple times. So we should filter that somewhere instead of adding the diaspora ID multiple times to the export. (That is also broken in the federation, we encrypt the message multiple times, but send it only once, because the target-url is used as a key)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are you still able to reinsert the contact in the correct aspects if you do that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, only the diaspora ID is used here. For the contacts the aspect names are exported here, so that are two different things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I think it should be okay to add
distinct
to the query in thePerson.in_aspects
scope.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's also what I would do. I didn't check if anything breaks, but I think it should work.