class DiasporaFederation::Entities::AccountMigration
This entity is sent when a person changes their diaspora* ID (e.g. when a user migration from one to another pod happens).
Public Class Methods
Calls super and additionally does signature verification for the instantiated entity.
@see DiasporaFederation::Entity.from_hash
# File lib/diaspora_federation/entities/account_migration.rb, line 70 def self.from_hash(*args) super.tap(&:verify_signature) end
Public Instance Methods
Returns diaspora* ID of the new person identity. @return [String] diaspora* ID of the new person identity
# File lib/diaspora_federation/entities/account_migration.rb, line 53 def new_identity profile&.author end
Returns diaspora* ID of the old person identity. @return [String] diaspora* ID of the old person identity
# File lib/diaspora_federation/entities/account_migration.rb, line 45 def old_identity return @old_identity if author_is_new_id? author end
Shortcut for calling super method with sensible arguments
@see DiasporaFederation::Entities::Signable#verify_signature
# File lib/diaspora_federation/entities/account_migration.rb, line 63 def verify_signature super(signer_id, :signature) end
Private Instance Methods
# File lib/diaspora_federation/entities/account_migration.rb, line 84 def enriched_properties super.tap do |hash| hash[:signature] = signature || sign_with_respective_key end end
Sign with the key of the signer_id
identity @raise [PrivateKeyNotFound] if the signer’s private key is not found @return [String] A Base64 encoded signature of signature_data
with key
# File lib/diaspora_federation/entities/account_migration.rb, line 93 def sign_with_respective_key privkey = DiasporaFederation.callbacks.trigger(:fetch_private_key, signer_id) raise PrivateKeyNotFound, "signer=#{signer_id} obj=#{self}" if privkey.nil? sign_with_key(privkey).tap do logger.info "event=sign status=complete signature=signature signer=#{signer_id} obj=#{self}" end end
# File lib/diaspora_federation/entities/account_migration.rb, line 80 def signer_id author_is_new_id? ? @old_identity : new_identity end