From b14de2dd9dd4fc7cc246c3290bc79401a52b16a1 Mon Sep 17 00:00:00 2001 From: Richard Ramos Date: Mon, 10 Oct 2022 11:21:27 -0400 Subject: [PATCH] fix: content topic in wakuv2 --- wakuv2/common/message.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/wakuv2/common/message.go b/wakuv2/common/message.go index 969b3c18d..7ce4454d9 100644 --- a/wakuv2/common/message.go +++ b/wakuv2/common/message.go @@ -152,9 +152,16 @@ type MemoryMessageStore struct { } func NewReceivedMessage(env *protocol.Envelope, msgType MessageType) *ReceivedMessage { + ct, err := ExtractTopicFromContentTopic(env.Message().ContentTopic) + if err != nil { + ct = new(TopicType) + } + return &ReceivedMessage{ Envelope: env, MsgType: msgType, + Sent: uint32(env.Message().Timestamp / int64(time.Second)), + Topic: *ct, } } @@ -227,7 +234,14 @@ func (msg *ReceivedMessage) Open(watcher *Filter) (result *ReceivedMessage) { result.Src = raw.PubKey result.Sent = uint32(msg.Envelope.Message().Timestamp / int64(time.Second)) - result.Topic = StringToTopic(msg.Envelope.Message().ContentTopic) + + ct, err := ExtractTopicFromContentTopic(msg.Envelope.Message().ContentTopic) + if err != nil { + log.Error("failed to decode message", "err", err) + return nil + } + + result.Topic = *ct return result }