Module: DiasporaFederation::Federation::Sender

Defined in:
lib/diaspora_federation/federation/sender.rb,
lib/diaspora_federation/federation/sender/hydra_wrapper.rb

Overview

Federation logic to send messages to other pods

Defined Under Namespace

Classes: HydraWrapper

Class Method Summary collapse

Class Method Details

.private(sender_id, obj_str, targets) ⇒ Hash

Send a private message to receive-urls

Parameters:

  • sender_id (String)

    sender diaspora-ID

  • obj_str (String)

    object string representation for logging (e.g. type@guid)

  • targets (Hash)

    Hash with receive-urls (key) of peoples with encrypted salmon-xml for them (value)

Returns:

  • (Hash)

    targets to retry



24
25
26
27
28
# File 'lib/diaspora_federation/federation/sender.rb', line 24

def self.private(sender_id, obj_str, targets)
  hydra = HydraWrapper.new(sender_id, obj_str)
  targets.each {|url, json| hydra.insert_enc_magic_env_request(url, json) }
  hydra.send.map {|url| [url, targets[url]] }.to_h
end

.public(sender_id, obj_str, urls, xml) ⇒ Array<String>

Send a public message to all urls

Parameters:

  • sender_id (String)

    sender diaspora-ID

  • obj_str (String)

    object string representation for logging (e.g. type@guid)

  • urls (Array<String>)

    receive-urls from pods

  • xml (String)

    salmon-xml

Returns:

  • (Array<String>)

    url to retry



12
13
14
15
16
# File 'lib/diaspora_federation/federation/sender.rb', line 12

def self.public(sender_id, obj_str, urls, xml)
  hydra = HydraWrapper.new(sender_id, obj_str)
  urls.each {|url| hydra.insert_magic_env_request(url, xml) }
  hydra.send
end