Radix Relay
Hybrid mesh communications with Signal Protocol encryption
Loading...
Searching...
No Matches
radix_relay::nostr::message_handler< Bridge > Class Template Reference

Handles processing of incoming and outgoing Nostr messages. More...

#include <message_handler.hpp>

Public Member Functions

 message_handler (std::shared_ptr< Bridge > bridge)
 Constructs a message handler.
 
auto handle (const nostr::events::incoming::encrypted_message &event) -> std::optional< core::events::message_received >
 Handles an incoming encrypted message event.
 
auto handle (const core::events::send &cmd) -> std::pair< std::string, std::vector< std::byte > >
 Handles a send command by encrypting and serializing a message.
 
auto handle (const core::events::publish_identity &) -> publish_bundle_result
 Handles a publish identity command by generating and serializing a bundle.
 
auto handle (const core::events::unpublish_identity &) -> std::pair< std::string, std::vector< std::byte > >
 Handles an unpublish identity command by generating an empty bundle.
 
auto handle (const core::events::trust &cmd) -> void
 Handles a trust command by assigning an alias to a peer.
 
auto handle (const core::events::establish_session &cmd) -> std::optional< core::events::session_established >
 Handles session establishment from bundle data.
 

Static Public Member Functions

static auto handle (const nostr::events::incoming::bundle_announcement &event) -> std::optional< std::variant< core::events::bundle_announcement_received, core::events::bundle_announcement_removed > >
 Handles an incoming bundle announcement event.
 
static auto handle (const core::events::subscribe &cmd) -> std::pair< std::string, std::vector< std::byte > >
 Handles a subscription request.
 
static auto handle (const nostr::events::incoming::ok &event) -> void
 Handles an incoming OK response (logs only).
 
static auto handle (const nostr::events::incoming::eose &event) -> void
 Handles an incoming EOSE marker (logs only).
 
static auto handle (const nostr::events::incoming::unknown_message &event) -> void
 Handles an unknown message type (logs warning).
 
static auto handle (const nostr::events::incoming::unknown_protocol &event) -> void
 Handles an unknown protocol message (logs warning).
 
static auto handle (const nostr::events::incoming::identity_announcement &) -> void
 Handles an incoming identity announcement (no-op).
 
static auto handle (const nostr::events::incoming::session_request &) -> void
 Handles an incoming session request (no-op).
 
static auto handle (const nostr::events::incoming::node_status &) -> void
 Handles an incoming node status update (no-op).
 

Detailed Description

template<concepts::signal_bridge Bridge>
class radix_relay::nostr::message_handler< Bridge >

Handles processing of incoming and outgoing Nostr messages.

Template Parameters
BridgeType satisfying the signal_bridge concept

Converts between Nostr events and internal event types, handling encryption/decryption, bundle management, and event serialization.

Definition at line 44 of file message_handler.hpp.

Constructor & Destructor Documentation

◆ message_handler()

template<concepts::signal_bridge Bridge>
radix_relay::nostr::message_handler< Bridge >::message_handler ( std::shared_ptr< Bridge >  bridge)
inlineexplicit

Constructs a message handler.

Parameters
bridgeSignal Protocol bridge for crypto operations

Definition at line 52 of file message_handler.hpp.

Member Function Documentation

◆ handle() [1/15]

template<concepts::signal_bridge Bridge>
auto radix_relay::nostr::message_handler< Bridge >::handle ( const core::events::establish_session cmd) -> std::optional<core::events::session_established>
inline

Handles session establishment from bundle data.

Parameters
cmdEstablish session command with bundle data
Returns
session_established event with peer RDX fingerprint

Definition at line 257 of file message_handler.hpp.

◆ handle() [2/15]

◆ handle() [3/15]

template<concepts::signal_bridge Bridge>
auto radix_relay::nostr::message_handler< Bridge >::handle ( const core::events::send cmd) -> std::pair<std::string, std::vector<std::byte>>
inline

◆ handle() [4/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const core::events::subscribe cmd) -> std::pair<std::string, std::vector<std::byte>>
inlinestatic

Handles a subscription request.

Parameters
cmdSubscribe command with JSON filter
Returns
Pair of subscription ID and serialized request bytes

Definition at line 270 of file message_handler.hpp.

◆ handle() [5/15]

template<concepts::signal_bridge Bridge>
auto radix_relay::nostr::message_handler< Bridge >::handle ( const core::events::trust cmd) -> void
inline

Handles a trust command by assigning an alias to a peer.

Parameters
cmdTrust command containing peer and alias

Definition at line 249 of file message_handler.hpp.

◆ handle() [6/15]

template<concepts::signal_bridge Bridge>
auto radix_relay::nostr::message_handler< Bridge >::handle ( const core::events::unpublish_identity ) -> std::pair<std::string, std::vector<std::byte>>
inline

◆ handle() [7/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::bundle_announcement event) -> std::optional< std::variant<core::events::bundle_announcement_received, core::events::bundle_announcement_removed>>
inlinestatic

Handles an incoming bundle announcement event.

Parameters
eventBundle announcement from Nostr relay
Returns
bundle_announcement_received if non-empty, bundle_announcement_removed if empty, std::nullopt on version mismatch

Definition at line 97 of file message_handler.hpp.

References radix_relay::nostr::protocol::bundle_announcement_minimum_version, radix_relay::nostr::extract_version_from_tags(), radix_relay::core::is_version_compatible(), radix_relay::core::events::bundle_announcement_received::pubkey, and radix_relay::core::events::bundle_announcement_removed::pubkey.

◆ handle() [8/15]

template<concepts::signal_bridge Bridge>
auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::encrypted_message event) -> std::optional<core::events::message_received>
inline

Handles an incoming encrypted message event.

Parameters
eventEncrypted message from Nostr relay
Returns
message_received event if decryption successful, std::nullopt on failure

Definition at line 60 of file message_handler.hpp.

References radix_relay::core::events::message_received::sender_rdx.

◆ handle() [9/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::eose event) -> void
inlinestatic

Handles an incoming EOSE marker (logs only).

Parameters
eventEOSE marker from relay

Definition at line 301 of file message_handler.hpp.

◆ handle() [10/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::identity_announcement ) -> void
inlinestatic

Handles an incoming identity announcement (no-op).

Parameters
eventIdentity announcement from relay

Definition at line 331 of file message_handler.hpp.

◆ handle() [11/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::node_status ) -> void
inlinestatic

Handles an incoming node status update (no-op).

Parameters
eventNode status from relay

Definition at line 345 of file message_handler.hpp.

◆ handle() [12/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::ok event) -> void
inlinestatic

Handles an incoming OK response (logs only).

Parameters
eventOK response from relay

Definition at line 288 of file message_handler.hpp.

◆ handle() [13/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::session_request ) -> void
inlinestatic

Handles an incoming session request (no-op).

Parameters
eventSession request from relay

Definition at line 338 of file message_handler.hpp.

◆ handle() [14/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::unknown_message event) -> void
inlinestatic

Handles an unknown message type (logs warning).

Parameters
eventUnknown message event

Definition at line 311 of file message_handler.hpp.

◆ handle() [15/15]

template<concepts::signal_bridge Bridge>
static auto radix_relay::nostr::message_handler< Bridge >::handle ( const nostr::events::incoming::unknown_protocol event) -> void
inlinestatic

Handles an unknown protocol message (logs warning).

Parameters
eventUnknown protocol event

Definition at line 321 of file message_handler.hpp.


The documentation for this class was generated from the following file: