From 79bf92bea595eb432ab2bd98bc8cc9acd4e16c40 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Tue, 18 Dec 2018 16:27:12 +0100 Subject: [PATCH] Allow specify topic in rpc endpoint (#1328) --- services/shhext/chat/rpc.go | 1 + services/shhext/chat/whisper.go | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/services/shhext/chat/rpc.go b/services/shhext/chat/rpc.go index 28cb0bc99..7592146de 100644 --- a/services/shhext/chat/rpc.go +++ b/services/shhext/chat/rpc.go @@ -17,6 +17,7 @@ type SendPublicMessageRPC struct { // SendDirectMessageRPC represents the RPC payload for the SendDirectMessage RPC method type SendDirectMessageRPC struct { Sig string + Chat string Payload hexutil.Bytes PubKey hexutil.Bytes } diff --git a/services/shhext/chat/whisper.go b/services/shhext/chat/whisper.go index c5409c645..1f6118c0f 100644 --- a/services/shhext/chat/whisper.go +++ b/services/shhext/chat/whisper.go @@ -34,10 +34,17 @@ func PublicMessageToWhisper(rpcMsg SendPublicMessageRPC, payload []byte) whisper } func DirectMessageToWhisper(rpcMsg SendDirectMessageRPC, payload []byte) whisper.NewMessage { + var topicBytes whisper.TopicType + + if rpcMsg.Chat == "" { + topicBytes = discoveryTopicBytes + } else { + topicBytes = toTopic(rpcMsg.Chat) + } msg := defaultWhisperMessage() - msg.Topic = discoveryTopicBytes + msg.Topic = topicBytes msg.Payload = payload msg.Sig = rpcMsg.Sig