diff --git a/channels/eventModel.go b/channels/eventModel.go index 9dbd9b4cfef3385814cb49289ddea16b032a0043..26db7539a4b8b5635b7dbfdb39b1714fa180199d 100644 --- a/channels/eventModel.go +++ b/channels/eventModel.go @@ -58,10 +58,13 @@ type EventModel interface { // // Nickname may be empty, in which case the UI is expected to display // the codename + // + // Message type is included in the call, it will always be Text (1) + // for this call, but it may be required in downstream databases ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, lease time.Duration, round rounds.Round, - status SentStatus) uint64 + mType MessageType, status SentStatus) uint64 // ReceiveReply is called whenever a message is received that is a reply on // a given channel. It may be called multiple times on the same message. It @@ -79,10 +82,14 @@ type EventModel interface { // // Nickname may be empty, in which case the UI is expected to display // the codename + // + // Message type is included in the call, it will always be Text (1) for + // this call, but it may be required in downstream databases ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 + lease time.Duration, round rounds.Round, mType MessageType, + status SentStatus) uint64 // ReceiveReaction is called whenever a reaction to a message is received // on a given channel. It may be called multiple times on the same reaction. @@ -102,10 +109,14 @@ type EventModel interface { // // Nickname may be empty, in which case the UI is expected to display // the codename + // + // Message type is included in the call, it will always be Reaction (3) for + // this call, but it may be required in downstream databases ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, reaction string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 + lease time.Duration, round rounds.Round, mType MessageType, + status SentStatus) uint64 // UpdateSentStatus is called whenever the sent status of a message has // changed. @@ -283,7 +294,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, var replyTo cryptoChannel.MessageID copy(replyTo[:], txt.ReplyMessageID) return e.model.ReceiveReply(channelID, messageID, replyTo, - nickname, txt.Text, identity, timestamp, lease, round, status) + nickname, txt.Text, identity, timestamp, lease, round, Text, status) } else { jww.ERROR.Printf("Failed process reply to for message %s from %s on "+ @@ -297,7 +308,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, } return e.model.ReceiveMessage(channelID, messageID, nickname, txt.Text, identity, - timestamp, lease, round, status) + timestamp, lease, round, Text, status) } // receiveReaction is the internal function that handles the reception of @@ -335,7 +346,7 @@ func (e *events) receiveReaction(channelID *id.ID, var reactTo cryptoChannel.MessageID copy(reactTo[:], react.ReactionMessageID) return e.model.ReceiveReaction(channelID, messageID, reactTo, nickname, - react.Reaction, identity, timestamp, lease, round, status) + react.Reaction, identity, timestamp, lease, round, Reaction, status) } else { jww.ERROR.Printf("Failed process reaction %s from %s on channel "+ "%s, type %s, ts: %s, lease: %s, round: %d, reacting to "+ diff --git a/channels/eventModel_test.go b/channels/eventModel_test.go index 5739d93dbe9859ea62aef2ccb9065e56d7c02e11..4e39fe96e6e01b50ff7dac4766ee580e9b30ddd1 100644 --- a/channels/eventModel_test.go +++ b/channels/eventModel_test.go @@ -57,7 +57,7 @@ func (*MockEvent) LeaveChannel(channelID *id.ID) {} func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, lease time.Duration, round rounds.Round, - status SentStatus) uint64 { + mType MessageType, status SentStatus) uint64 { m.eventReceive = eventReceive{ channelID: channelID, messageID: messageID, @@ -73,7 +73,7 @@ func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.Mes func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 { + lease time.Duration, round rounds.Round, mType MessageType, status SentStatus) uint64 { fmt.Println(reactionTo) m.eventReceive = eventReceive{ channelID: channelID, @@ -90,7 +90,7 @@ func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa func (m *MockEvent) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, reaction string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 { + lease time.Duration, round rounds.Round, mType MessageType, status SentStatus) uint64 { m.eventReceive = eventReceive{ channelID: channelID, messageID: messageID, diff --git a/channels/joinedChannel_test.go b/channels/joinedChannel_test.go index d83daa72748f6cd1676bcaee80f14064ef8e54e8..a8a21f666ebd959ebb2d0d082edb414680221450 100644 --- a/channels/joinedChannel_test.go +++ b/channels/joinedChannel_test.go @@ -626,18 +626,18 @@ func (m *mockEventModel) LeaveChannel(c *id.ID) { func (m *mockEventModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, lease time.Duration, round rounds.Round, - status SentStatus) uint64 { + mType MessageType, status SentStatus) uint64 { return 0 } func (m *mockEventModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, text string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 { + lease time.Duration, round rounds.Round, mType MessageType, status SentStatus) uint64 { return 0 } func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, nickname, reaction string, identity cryptoChannel.Identity, timestamp time.Time, - lease time.Duration, round rounds.Round, status SentStatus) uint64 { + lease time.Duration, round rounds.Round, mType MessageType, status SentStatus) uint64 { return 0 }