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 }