Module: DiasporaFederation::Federation::Receiver
- Extended by:
- Logging
- Defined in:
- lib/diaspora_federation/federation/receiver.rb,
lib/diaspora_federation/federation/receiver/public.rb,
lib/diaspora_federation/federation/receiver/private.rb,
lib/diaspora_federation/federation/receiver/exceptions.rb,
lib/diaspora_federation/federation/receiver/abstract_receiver.rb
Overview
This module parses and receives entities.
Defined Under Namespace
Classes: AbstractReceiver, InvalidSender, NotPublic, Private, Public, RecipientRequired
Class Method Summary collapse
-
.receive_private(data, recipient_private_key, recipient_id) ⇒ Object
Receive a private message.
-
.receive_public(data) ⇒ Object
Receive a public message.
Methods included from Logging
Class Method Details
.receive_private(data, recipient_private_key, recipient_id) ⇒ Object
Receive a private message
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/diaspora_federation/federation/receiver.rb', line 26 def self.receive_private(data, recipient_private_key, recipient_id) raise ArgumentError, "no recipient key provided" unless recipient_private_key.instance_of?(OpenSSL::PKey::RSA) magic_env_xml = Salmon::EncryptedMagicEnvelope.decrypt(data, recipient_private_key) magic_env = Salmon::MagicEnvelope.unenvelop(magic_env_xml) Private.new(magic_env, recipient_id).receive rescue => e # rubocop:disable Style/RescueStandardError logger.error "failed to receive private message for #{recipient_id}: #{e.class}: #{e.}" logger.debug "received data:\n#{data}" raise e end |
.receive_public(data) ⇒ Object
Receive a public message
11 12 13 14 15 16 17 18 19 |
# File 'lib/diaspora_federation/federation/receiver.rb', line 11 def self.receive_public(data) magic_env_xml = Nokogiri::XML(data).root magic_env = Salmon::MagicEnvelope.unenvelop(magic_env_xml) Public.new(magic_env).receive rescue => e # rubocop:disable Style/RescueStandardError logger.error "failed to receive public message: #{e.class}: #{e.}" logger.debug "received data:\n#{data}" raise e end |