diff --git a/channels/eventModel.go b/channels/eventModel.go index 403287adb7ab71fd3164d4bbbe5eb6931f357de4..08ef48f227bc126c04677d48703be1692a764e52 100644 --- a/channels/eventModel.go +++ b/channels/eventModel.go @@ -8,6 +8,7 @@ package channels import ( + "fmt" "github.com/golang/protobuf/proto" jww "github.com/spf13/jwalterweatherman" "gitlab.com/elixxir/client/cmix/identity/receptionID" @@ -226,6 +227,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, senderUsername string, content []byte, timestamp time.Time, lease time.Duration, round rounds.Round) { txt := &CMIXChannelText{} + if err := proto.Unmarshal(content, txt); err != nil { jww.ERROR.Printf("Failed to text unmarshal message %s from %s on "+ "channel %s, type %s, ts: %s, lease: %s, round: %d: %+v", @@ -235,9 +237,12 @@ func (e *events) receiveTextMessage(channelID *id.ID, } if txt.ReplyMessageID != nil { + if len(txt.ReplyMessageID) == cryptoChannel.MessageIDLen { var replyTo cryptoChannel.MessageID copy(replyTo[:], txt.ReplyMessageID) + e.model.ReceiveReply(channelID, messageID, replyTo, + senderUsername, txt.Text, timestamp, lease, round) return } else { @@ -251,6 +256,8 @@ func (e *events) receiveTextMessage(channelID *id.ID, } } + fmt.Println(channelID) + e.model.ReceiveMessage(channelID, messageID, senderUsername, txt.Text, timestamp, lease, round) } diff --git a/channels/eventModel_test.go b/channels/eventModel_test.go index a144be353192276de837fac237de9a5e0ba3a5d2..b15dfd2501d5b9f023362837d117ef65efb37169 100644 --- a/channels/eventModel_test.go +++ b/channels/eventModel_test.go @@ -9,6 +9,7 @@ package channels import ( "bytes" + "fmt" "github.com/golang/protobuf/proto" "gitlab.com/elixxir/client/cmix/identity/receptionID" "gitlab.com/elixxir/client/cmix/rounds" @@ -83,6 +84,7 @@ func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa replyTo cryptoChannel.MessageID, senderUsername string, text string, timestamp time.Time, lease time.Duration, round rounds.Round) { + fmt.Println(replyTo) m.eventReceive = eventReceive{ channelID: channelID, messageID: messageID, @@ -537,7 +539,7 @@ func TestEvents_receiveTextMessage_Reply(t *testing.T) { r.Timestamps[states.QUEUED] = time.Now() //call the handler - e.receiveTextMessage(chID, msgID, 0, senderUsername, + e.receiveTextMessage(chID, msgID, Text, senderUsername, textMarshaled, ts, lease, r) //check the results on the model