Class: DiasporaFederation::Federation::Receiver::AbstractReceiver

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/diaspora_federation/federation/receiver/abstract_receiver.rb

Overview

Common functionality for receivers

Direct Known Subclasses

Private, Public

Instance Method Summary collapse

Methods included from Logging

included

Constructor Details

#initialize(magic_envelope, recipient_id = nil) ⇒ AbstractReceiver

Creates a new receiver

Parameters:

  • magic_envelope (MagicEnvelope)

    the received magic envelope

  • recipient_id (Object) (defaults to: nil)

    the identifier of the recipient of a private message



13
14
15
16
17
# File 'lib/diaspora_federation/federation/receiver/abstract_receiver.rb', line 13

def initialize(magic_envelope, recipient_id=nil)
  @entity = magic_envelope.payload
  @sender = magic_envelope.sender
  @recipient_id = recipient_id
end

Instance Method Details

#receiveObject

Validates and receives the entity



20
21
22
23
24
25
# File 'lib/diaspora_federation/federation/receiver/abstract_receiver.rb', line 20

def receive
  validate_and_receive
rescue => e # rubocop:disable Style/RescueStandardError
  logger.error "failed to receive #{entity}"
  raise e
end