Class: DiasporaFederation::Discovery::Discovery

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/diaspora_federation/discovery/discovery.rb

Overview

This class contains the logic to fetch all data for the given diaspora* ID.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Logging

included

Constructor Details

#initialize(diaspora_id) ⇒ Discovery

Creates a discovery class for the diaspora* ID

Parameters:

  • diaspora_id (String)

    the diaspora* ID to discover



14
15
16
# File 'lib/diaspora_federation/discovery/discovery.rb', line 14

def initialize(diaspora_id)
  @diaspora_id = clean_diaspora_id(diaspora_id)
end

Instance Attribute Details

#diaspora_idString (readonly)

Returns the diaspora* ID of the account.

Returns:

  • (String)

    the diaspora* ID of the account



10
11
12
# File 'lib/diaspora_federation/discovery/discovery.rb', line 10

def diaspora_id
  @diaspora_id
end

Instance Method Details

#fetch_and_savePerson

Fetches all metadata for the account and saves it via callback

Returns:

  • (Person)

Raises:



21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/diaspora_federation/discovery/discovery.rb', line 21

def fetch_and_save
  logger.info "Fetch data for #{diaspora_id}"

  validate_diaspora_id

  DiasporaFederation.callbacks.trigger(:save_person_after_webfinger, person)
  logger.info "Successfully webfingered #{diaspora_id}"
  person
rescue DiscoveryError
  raise # simply re-raise DiscoveryError
rescue => e # rubocop:disable Style/RescueStandardError
  raise DiscoveryError, "Failed discovery for #{diaspora_id}: #{e.class}: #{e.message}"
end