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



12
13
14
# File 'lib/diaspora_federation/discovery/discovery.rb', line 12

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



8
9
10
# File 'lib/diaspora_federation/discovery/discovery.rb', line 8

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:



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

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