diff --git a/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs b/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs --- a/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs +++ b/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs @@ -18,6 +18,13 @@ .unwrap_or("https://[::1]:50051".to_string()); } +#[napi(object)] +pub struct MessageToDeliver { + pub message_id: String, + pub from_device_id: String, + pub payload: String, +} + #[napi] pub struct TunnelbrokerClient { tx: mpsc::Sender, @@ -28,7 +35,7 @@ #[napi(constructor)] pub fn new( device_id: String, - on_receive_callback: ThreadsafeFunction, + on_receive_callback: ThreadsafeFunction, ) -> Self { let mut client = tunnelbroker::initialize_client(TUNNELBROKER_SERVICE_ADDR.to_string()); @@ -57,7 +64,11 @@ MessagesToDeliver(messages_to_send) => { for message in messages_to_send.messages { on_receive_callback.call( - Ok(message.payload), + Ok(MessageToDeliver { + message_id: message.message_id, + from_device_id: message.from_device_id, + payload: message.payload, + }), ThreadsafeFunctionCallMode::NonBlocking, ); } diff --git a/lib/types/rust-binding-types.js b/lib/types/rust-binding-types.js --- a/lib/types/rust-binding-types.js +++ b/lib/types/rust-binding-types.js @@ -1,8 +1,14 @@ // @flow +type TunnelbrokerMessageToDeliver = { + +messageId: string, + +fromDeviceId: string, + +payload: string, +}; + type tunnelbrokerOnReceiveCallback = ( err: Error | null, - payload: string, + message: TunnelbrokerMessageToDeliver, ) => mixed; declare class TunnelbrokerClientClass {