fix: content topic in wakuv2

This commit is contained in:
Richard Ramos 2022-10-10 11:21:27 -04:00 committed by RichΛrd
parent d4d35710be
commit b14de2dd9d
1 changed files with 15 additions and 1 deletions

View File

@ -152,9 +152,16 @@ type MemoryMessageStore struct {
} }
func NewReceivedMessage(env *protocol.Envelope, msgType MessageType) *ReceivedMessage { func NewReceivedMessage(env *protocol.Envelope, msgType MessageType) *ReceivedMessage {
ct, err := ExtractTopicFromContentTopic(env.Message().ContentTopic)
if err != nil {
ct = new(TopicType)
}
return &ReceivedMessage{ return &ReceivedMessage{
Envelope: env, Envelope: env,
MsgType: msgType, 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.Src = raw.PubKey
result.Sent = uint32(msg.Envelope.Message().Timestamp / int64(time.Second)) 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 return result
} }