Class: DiasporaFederation::Entities::AccountMigration

Inherits:
DiasporaFederation::Entity show all
Includes:
Signable
Defined in:
lib/diaspora_federation/entities/account_migration.rb,
lib/diaspora_federation/entities/account_migration/signable.rb

Overview

This entity is sent when a person changes their diaspora* ID (e.g. when a user migration from one to another pod happens).

Defined Under Namespace

Modules: Signable Classes: PrivateKeyNotFound

Constant Summary

Constants included from Signable

Signable::DIGEST

Constants inherited from DiasporaFederation::Entity

DiasporaFederation::Entity::ENTITY_NAME_REGEX, DiasporaFederation::Entity::INVALID_XML_REGEX

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Signable

#signature_data, #unique_migration_descriptor

Methods included from Signable

#sign_with_key, #signature_data

Methods included from Logging

included

Methods inherited from DiasporaFederation::Entity

class_name, entity_class, entity_name, from_json, from_xml, #initialize, #to_h, #to_json, #to_xml

Methods included from PropertiesDSL

#class_props, #default_values, #entity, #find_property_for_xml_name, #missing_props, #optional_props, #property, #resolv_aliases, #xml_names

Constructor Details

This class inherits a constructor from DiasporaFederation::Entity

Instance Attribute Details

#authorString (readonly)

Sender of the AccountMigration message. Usually it is the old diaspora* ID of the person who changes their ID. This property is also allowed to be the new diaspora* ID, which is equal to the author of the included profile.

Returns:

  • (String)

    author diaspora* ID

See Also:



16
# File 'lib/diaspora_federation/entities/account_migration.rb', line 16

property :author, :string

#old_identityString (readonly)

Returns diaspora* ID of the old person identity.

Returns:

  • (String)

    diaspora* ID of the old person identity



34
# File 'lib/diaspora_federation/entities/account_migration.rb', line 34

property :old_identity, :string, default: nil

#profilePerson (readonly)

Holds new updated profile of a person, including diaspora* ID

Returns:

  • (Person)

    person new data



21
# File 'lib/diaspora_federation/entities/account_migration.rb', line 21

entity :profile, Entities::Profile

#signatureString (readonly)

Signature that validates original and target diaspora* IDs with the private key of the second identity, other than the entity author. So if the author is the old identity then this signature is made with the new identity key, and vice versa.

Returns:

  • (String)

    signature



28
# File 'lib/diaspora_federation/entities/account_migration.rb', line 28

property :signature, :string, default: nil

Class Method Details

.from_hash(*args) ⇒ Object

Calls super and additionally does signature verification for the instantiated entity.



62
63
64
# File 'lib/diaspora_federation/entities/account_migration.rb', line 62

def self.from_hash(*args)
  super.tap(&:verify_signature)
end

Instance Method Details

#new_identityString

Returns diaspora* ID of the new person identity.

Returns:

  • (String)

    diaspora* ID of the new person identity



45
46
47
# File 'lib/diaspora_federation/entities/account_migration.rb', line 45

def new_identity
  profile.author if profile
end

#verify_signatureObject

Shortcut for calling super method with sensible arguments



55
56
57
# File 'lib/diaspora_federation/entities/account_migration.rb', line 55

def verify_signature
  super(signer_id, :signature)
end