Skip to content
Snippets Groups Projects
Commit d0367733 authored by benjamin's avatar benjamin
Browse files

changed the event model to always pass over message type numbers

parent 8251db7e
No related branches found
No related tags found
4 merge requests!510Release,!419rewrote the health tracker to both consider if there are waiting rounds and...,!397Fully Decentralized channels,!340Project/channels
...@@ -58,10 +58,13 @@ type EventModel interface { ...@@ -58,10 +58,13 @@ type EventModel interface {
// //
// Nickname may be empty, in which case the UI is expected to display // Nickname may be empty, in which case the UI is expected to display
// the codename // 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, ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID,
nickname, text string, identity cryptoChannel.Identity, nickname, text string, identity cryptoChannel.Identity,
timestamp time.Time, lease time.Duration, round rounds.Round, 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 // 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 // a given channel. It may be called multiple times on the same message. It
...@@ -79,10 +82,14 @@ type EventModel interface { ...@@ -79,10 +82,14 @@ type EventModel interface {
// //
// Nickname may be empty, in which case the UI is expected to display // Nickname may be empty, in which case the UI is expected to display
// the codename // 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, ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, text string, reactionTo cryptoChannel.MessageID, nickname, text string,
identity cryptoChannel.Identity, timestamp time.Time, 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 // 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. // on a given channel. It may be called multiple times on the same reaction.
...@@ -102,10 +109,14 @@ type EventModel interface { ...@@ -102,10 +109,14 @@ type EventModel interface {
// //
// Nickname may be empty, in which case the UI is expected to display // Nickname may be empty, in which case the UI is expected to display
// the codename // 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, ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, reaction string, reactionTo cryptoChannel.MessageID, nickname, reaction string,
identity cryptoChannel.Identity, timestamp time.Time, 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 // UpdateSentStatus is called whenever the sent status of a message has
// changed. // changed.
...@@ -283,7 +294,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, ...@@ -283,7 +294,7 @@ func (e *events) receiveTextMessage(channelID *id.ID,
var replyTo cryptoChannel.MessageID var replyTo cryptoChannel.MessageID
copy(replyTo[:], txt.ReplyMessageID) copy(replyTo[:], txt.ReplyMessageID)
return e.model.ReceiveReply(channelID, messageID, replyTo, 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 { } else {
jww.ERROR.Printf("Failed process reply to for message %s from %s on "+ jww.ERROR.Printf("Failed process reply to for message %s from %s on "+
...@@ -297,7 +308,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, ...@@ -297,7 +308,7 @@ func (e *events) receiveTextMessage(channelID *id.ID,
} }
return e.model.ReceiveMessage(channelID, messageID, nickname, txt.Text, identity, 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 // receiveReaction is the internal function that handles the reception of
...@@ -335,7 +346,7 @@ func (e *events) receiveReaction(channelID *id.ID, ...@@ -335,7 +346,7 @@ func (e *events) receiveReaction(channelID *id.ID,
var reactTo cryptoChannel.MessageID var reactTo cryptoChannel.MessageID
copy(reactTo[:], react.ReactionMessageID) copy(reactTo[:], react.ReactionMessageID)
return e.model.ReceiveReaction(channelID, messageID, reactTo, nickname, return e.model.ReceiveReaction(channelID, messageID, reactTo, nickname,
react.Reaction, identity, timestamp, lease, round, status) react.Reaction, identity, timestamp, lease, round, Reaction, status)
} else { } else {
jww.ERROR.Printf("Failed process reaction %s from %s on channel "+ jww.ERROR.Printf("Failed process reaction %s from %s on channel "+
"%s, type %s, ts: %s, lease: %s, round: %d, reacting to "+ "%s, type %s, ts: %s, lease: %s, round: %d, reacting to "+
......
...@@ -57,7 +57,7 @@ func (*MockEvent) LeaveChannel(channelID *id.ID) {} ...@@ -57,7 +57,7 @@ func (*MockEvent) LeaveChannel(channelID *id.ID) {}
func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID,
nickname, text string, identity cryptoChannel.Identity, nickname, text string, identity cryptoChannel.Identity,
timestamp time.Time, lease time.Duration, round rounds.Round, timestamp time.Time, lease time.Duration, round rounds.Round,
status SentStatus) uint64 { mType MessageType, status SentStatus) uint64 {
m.eventReceive = eventReceive{ m.eventReceive = eventReceive{
channelID: channelID, channelID: channelID,
messageID: messageID, messageID: messageID,
...@@ -73,7 +73,7 @@ func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.Mes ...@@ -73,7 +73,7 @@ func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.Mes
func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, text string, reactionTo cryptoChannel.MessageID, nickname, text string,
identity cryptoChannel.Identity, timestamp time.Time, 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) fmt.Println(reactionTo)
m.eventReceive = eventReceive{ m.eventReceive = eventReceive{
channelID: channelID, channelID: channelID,
...@@ -90,7 +90,7 @@ func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa ...@@ -90,7 +90,7 @@ func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa
func (m *MockEvent) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *MockEvent) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, reaction string, reactionTo cryptoChannel.MessageID, nickname, reaction string,
identity cryptoChannel.Identity, timestamp time.Time, 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{ m.eventReceive = eventReceive{
channelID: channelID, channelID: channelID,
messageID: messageID, messageID: messageID,
......
...@@ -626,18 +626,18 @@ func (m *mockEventModel) LeaveChannel(c *id.ID) { ...@@ -626,18 +626,18 @@ func (m *mockEventModel) LeaveChannel(c *id.ID) {
func (m *mockEventModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *mockEventModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID,
nickname, text string, identity cryptoChannel.Identity, nickname, text string, identity cryptoChannel.Identity,
timestamp time.Time, lease time.Duration, round rounds.Round, timestamp time.Time, lease time.Duration, round rounds.Round,
status SentStatus) uint64 { mType MessageType, status SentStatus) uint64 {
return 0 return 0
} }
func (m *mockEventModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *mockEventModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, text string, reactionTo cryptoChannel.MessageID, nickname, text string,
identity cryptoChannel.Identity, timestamp time.Time, 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 return 0
} }
func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, func (m *mockEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, reaction string, reactionTo cryptoChannel.MessageID, nickname, reaction string,
identity cryptoChannel.Identity, timestamp time.Time, 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 return 0
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment