Add remote_photo_path to AccountMigration entity
This can be set to the URL on the new pod when photos were migrated/imported, so other pods can adjust the `remote_photo_path` of the photos of the old account.
This commit is contained in:
parent
85e12cea93
commit
0d12770262
6 changed files with 54 additions and 3 deletions
|
|
@ -15,8 +15,9 @@ This entity is sent when a person changes their diaspora* ID (e.g. when a user m
|
||||||
## Optional Properties
|
## Optional Properties
|
||||||
|
|
||||||
| Property | Type | Description |
|
| Property | Type | Description |
|
||||||
| ----------- | ---------------------------- | ------------------------------------------------------------------------------------ |
|
| ------------------- | ---------------------------- | ------------------------------------------------------------------------------------ |
|
||||||
| `old_identity` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the closed account. This field is mandatory if the author of the entity is the new identity. |
|
| `old_identity` | [diaspora\* ID][diaspora-id] | The diaspora\* ID of the closed account. This field is mandatory if the author of the entity is the new identity. |
|
||||||
|
| `remote_photo_path` | [URL][url] | The URL to the path (without filenames) of the migrated photos on the new pod. |
|
||||||
|
|
||||||
|
|
||||||
### Signature
|
### Signature
|
||||||
|
|
@ -59,9 +60,11 @@ AccountMigration:old-diaspora-id@example.org:new-diaspora-id@example.com
|
||||||
07b1OIY6sTUQwV5pbpgFK0uz6W4cu+oQnlg410Q4uISUOdNOlBdYqhZJm62VFhgvzt4TZXfiJgoupFkRjP0BsaVaZuP2zKMNvO3ngWOeJRf2oRK4Ub5cEA/g7yijkRc+7y8r1iLJ31MFb1czyeCsLxw9Ol8SvAJddogGiLHDhjE=
|
07b1OIY6sTUQwV5pbpgFK0uz6W4cu+oQnlg410Q4uISUOdNOlBdYqhZJm62VFhgvzt4TZXfiJgoupFkRjP0BsaVaZuP2zKMNvO3ngWOeJRf2oRK4Ub5cEA/g7yijkRc+7y8r1iLJ31MFb1czyeCsLxw9Ol8SvAJddogGiLHDhjE=
|
||||||
</signature>
|
</signature>
|
||||||
<old_identity>alice@example.org</old_identity>
|
<old_identity>alice@example.org</old_identity>
|
||||||
|
<remote_photo_path>https://newpod.example.net/uploads/images/</remote_photo_path>
|
||||||
</account_migration>
|
</account_migration>
|
||||||
~~~
|
~~~
|
||||||
|
|
||||||
[diaspora-id]: {{ site.baseurl }}/federation/types.html#diaspora-id
|
[diaspora-id]: {{ site.baseurl }}/federation/types.html#diaspora-id
|
||||||
[profile]: {{ site.baseurl }}/entities/profile.html
|
[profile]: {{ site.baseurl }}/entities/profile.html
|
||||||
[signature]: {{ site.baseurl }}/federation/types.html#signature
|
[signature]: {{ site.baseurl }}/federation/types.html#signature
|
||||||
|
[url]: {{ site.baseurl }}/federation/types.html#url
|
||||||
|
|
|
||||||
|
|
@ -33,6 +33,11 @@ module DiasporaFederation
|
||||||
# @return [String] old identity
|
# @return [String] old identity
|
||||||
property :old_identity, :string, default: nil
|
property :old_identity, :string, default: nil
|
||||||
|
|
||||||
|
# @!attribute [r] remote_photo_path
|
||||||
|
# The url to the path of the photos on the new pod. Can be empty if photos weren't migrated.
|
||||||
|
# @return [String] remote photo path
|
||||||
|
property :remote_photo_path, :string, optional: true
|
||||||
|
|
||||||
# Returns diaspora* ID of the old person identity.
|
# Returns diaspora* ID of the old person identity.
|
||||||
# @return [String] diaspora* ID of the old person identity
|
# @return [String] diaspora* ID of the old person identity
|
||||||
def old_identity
|
def old_identity
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,7 @@ module DiasporaFederation
|
||||||
author { Fabricate.sequence(:diaspora_id) }
|
author { Fabricate.sequence(:diaspora_id) }
|
||||||
profile {|attrs| Fabricate(:profile_entity, author: attrs[:author]) }
|
profile {|attrs| Fabricate(:profile_entity, author: attrs[:author]) }
|
||||||
old_identity { Fabricate.sequence(:diaspora_id) }
|
old_identity { Fabricate.sequence(:diaspora_id) }
|
||||||
|
remote_photo_path "https://diaspora.example.tld/uploads/images/"
|
||||||
end
|
end
|
||||||
|
|
||||||
Fabricator(:person_entity, class_name: DiasporaFederation::Entities::Person) do
|
Fabricator(:person_entity, class_name: DiasporaFederation::Entities::Person) do
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,8 @@ module DiasporaFederation
|
||||||
rule :profile, :not_nil
|
rule :profile, :not_nil
|
||||||
|
|
||||||
rule :old_identity, :diaspora_id
|
rule :old_identity, :diaspora_id
|
||||||
|
|
||||||
|
rule :remote_photo_path, URI: [:path]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ module DiasporaFederation
|
||||||
properties = described_class.new(hash).send(:enriched_properties)
|
properties = described_class.new(hash).send(:enriched_properties)
|
||||||
hash[:signature] = properties[:signature]
|
hash[:signature] = properties[:signature]
|
||||||
hash[:profile] = Entities::Profile.new(hash[:profile].to_h.tap {|profile| profile[:edited_at] = nil })
|
hash[:profile] = Entities::Profile.new(hash[:profile].to_h.tap {|profile| profile[:edited_at] = nil })
|
||||||
|
hash[:remote_photo_path] = "http://localhost:3000/uploads/images/"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let(:signature_data) { "AccountMigration:#{old_diaspora_id}:#{new_diaspora_id}" }
|
let(:signature_data) { "AccountMigration:#{old_diaspora_id}:#{new_diaspora_id}" }
|
||||||
|
|
@ -126,6 +127,7 @@ module DiasporaFederation
|
||||||
</profile>
|
</profile>
|
||||||
<signature>#{data[:signature]}</signature>
|
<signature>#{data[:signature]}</signature>
|
||||||
<old_identity>#{data[:old_identity]}</old_identity>
|
<old_identity>#{data[:old_identity]}</old_identity>
|
||||||
|
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||||
</account_migration>
|
</account_migration>
|
||||||
XML
|
XML
|
||||||
|
|
||||||
|
|
@ -165,6 +167,7 @@ XML
|
||||||
</profile>
|
</profile>
|
||||||
<signature>#{data[:signature]}</signature>
|
<signature>#{data[:signature]}</signature>
|
||||||
<old_identity>#{data[:old_identity]}</old_identity>
|
<old_identity>#{data[:old_identity]}</old_identity>
|
||||||
|
<remote_photo_path>#{data[:remote_photo_path]}</remote_photo_path>
|
||||||
</account_migration>
|
</account_migration>
|
||||||
XML
|
XML
|
||||||
|
|
||||||
|
|
@ -217,5 +220,31 @@ XML
|
||||||
}.to raise_error Entity::ValidationError
|
}.to raise_error Entity::ValidationError
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
context "optional values" do
|
||||||
|
let(:hash) {
|
||||||
|
{
|
||||||
|
author: old_diaspora_id,
|
||||||
|
profile: Entities::Profile.new(author: new_diaspora_id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
it "uses default values when parsing" do
|
||||||
|
minimal_xml = <<-XML
|
||||||
|
<account_migration>
|
||||||
|
<author>#{data[:author]}</author>
|
||||||
|
<profile>
|
||||||
|
<author>#{data[:profile].author}</author>
|
||||||
|
</profile>
|
||||||
|
<signature>#{data[:signature]}</signature>
|
||||||
|
</account_migration>
|
||||||
|
XML
|
||||||
|
|
||||||
|
parsed_xml = Nokogiri::XML(minimal_xml).root
|
||||||
|
parsed_instance = Entity.entity_class(parsed_xml.name).from_xml(parsed_xml)
|
||||||
|
expect(parsed_instance.old_identity).to eq(data[:author])
|
||||||
|
expect(parsed_instance.remote_photo_path).to be_nil
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -21,5 +21,16 @@ module DiasporaFederation
|
||||||
let(:property) { :old_identity }
|
let(:property) { :old_identity }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "#remote_photo_path" do
|
||||||
|
let(:property) { :remote_photo_path }
|
||||||
|
|
||||||
|
it_behaves_like "a property with a value validation/restriction" do
|
||||||
|
let(:wrong_values) { [] }
|
||||||
|
let(:correct_values) { [nil] }
|
||||||
|
end
|
||||||
|
|
||||||
|
it_behaves_like "a url path validator"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue