diff --git a/channels/eventModel.go b/channels/eventModel.go index 08ef48f227bc126c04677d48703be1692a764e52..1a244956b3a88237f1b11b188fc6a0ae40408232 100644 --- a/channels/eventModel.go +++ b/channels/eventModel.go @@ -47,8 +47,8 @@ type EventModel interface { // It may be called multiple times on the same message, it is incumbent on // the user of the API to filter such called by message ID ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, - senderUsername string, text string, - timestamp time.Time, lease time.Duration, round rounds.Round) + senderUsername string, text string, timestamp time.Time, + lease time.Duration, round rounds.Round, status SentStatus) // ReceiveReply is called whenever a message is received which is a reply // on a given channel. It may be called multiple times on the same message, @@ -58,7 +58,7 @@ type EventModel interface { ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, senderUsername string, text string, timestamp time.Time, lease time.Duration, - round rounds.Round) + round rounds.Round, status SentStatus) // 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, @@ -68,26 +68,7 @@ type EventModel interface { ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, senderUsername string, reaction string, timestamp time.Time, lease time.Duration, - round rounds.Round) - - // MessageSent is called whenever the user sends a message. It should be - //designated as "sent" and that delivery is unknown. - MessageSent(channelID *id.ID, messageID cryptoChannel.MessageID, - myUsername string, text string, timestamp time.Time, - lease time.Duration, round rounds.Round) - - // ReplySent is called whenever the user sends a reply. It should be - // designated as "sent" and that delivery is unknown. - ReplySent(channelID *id.ID, messageID cryptoChannel.MessageID, - replyTo cryptoChannel.MessageID, myUsername string, text string, - timestamp time.Time, lease time.Duration, round rounds.Round) - - // ReactionSent is called whenever the user sends a reply. It should be - // designated as "sent" and that delivery is unknown. - ReactionSent(channelID *id.ID, messageID cryptoChannel.MessageID, - reactionTo cryptoChannel.MessageID, senderUsername string, - reaction string, timestamp time.Time, lease time.Duration, - round rounds.Round) + round rounds.Round, status SentStatus) // UpdateSentStatus is called whenever the sent status of a message // has changed @@ -242,7 +223,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, var replyTo cryptoChannel.MessageID copy(replyTo[:], txt.ReplyMessageID) e.model.ReceiveReply(channelID, messageID, replyTo, - senderUsername, txt.Text, timestamp, lease, round) + senderUsername, txt.Text, timestamp, lease, round, Delivered) return } else { @@ -259,7 +240,7 @@ func (e *events) receiveTextMessage(channelID *id.ID, fmt.Println(channelID) e.model.ReceiveMessage(channelID, messageID, senderUsername, txt.Text, - timestamp, lease, round) + timestamp, lease, round, Delivered) } // receiveReaction is the internal function which handles the reception of @@ -295,7 +276,7 @@ func (e *events) receiveReaction(channelID *id.ID, var reactTo cryptoChannel.MessageID copy(reactTo[:], react.ReactionMessageID) e.model.ReceiveReaction(channelID, messageID, reactTo, senderUsername, - react.Reaction, timestamp, lease, round) + react.Reaction, timestamp, lease, round, Delivered) } 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 b15dfd2501d5b9f023362837d117ef65efb37169..5241c9fc6acb1796aa1af20a435c3d0b349aa279 100644 --- a/channels/eventModel_test.go +++ b/channels/eventModel_test.go @@ -38,26 +38,6 @@ type MockEvent struct { eventReceive } -func (m *MockEvent) MessageSent(channelID *id.ID, messageID cryptoChannel.MessageID, - myUsername string, text string, timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - -func (m *MockEvent) ReplySent(channelID *id.ID, messageID cryptoChannel.MessageID, - replyTo cryptoChannel.MessageID, myUsername string, text string, - timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - -func (m *MockEvent) ReactionSent(channelID *id.ID, messageID cryptoChannel.MessageID, - reactionTo cryptoChannel.MessageID, senderUsername string, reaction string, - timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - func (m *MockEvent) UpdateSentStatus(messageID cryptoChannel.MessageID, status SentStatus) { //TODO implement me @@ -68,7 +48,7 @@ func (*MockEvent) JoinChannel(channel *cryptoBroadcast.Channel) {} func (*MockEvent) LeaveChannel(channelID *id.ID) {} func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID, senderUsername string, text string, - timestamp time.Time, lease time.Duration, round rounds.Round) { + timestamp time.Time, lease time.Duration, round rounds.Round, status SentStatus) { m.eventReceive = eventReceive{ channelID: channelID, messageID: messageID, @@ -83,7 +63,7 @@ func (m *MockEvent) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.Mes func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.MessageID, replyTo cryptoChannel.MessageID, senderUsername string, text string, timestamp time.Time, lease time.Duration, - round rounds.Round) { + round rounds.Round, status SentStatus) { fmt.Println(replyTo) m.eventReceive = eventReceive{ channelID: channelID, @@ -99,7 +79,7 @@ func (m *MockEvent) ReceiveReply(channelID *id.ID, messageID cryptoChannel.Messa func (m *MockEvent) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, senderUsername string, reaction string, timestamp time.Time, lease time.Duration, - round rounds.Round) { + round rounds.Round, status SentStatus) { m.eventReceive = eventReceive{ channelID: channelID, messageID: messageID, diff --git a/channels/joinedChannel_test.go b/channels/joinedChannel_test.go index 0ec8ee56684e2029c23e4e7213af17f6cfb51929..ba20c46dcece6249505c7d724286f5e40d0f0e1e 100644 --- a/channels/joinedChannel_test.go +++ b/channels/joinedChannel_test.go @@ -504,26 +504,6 @@ type mockEventModel struct { leftCh *id.ID } -func (m *mockEventModel) MessageSent(channelID *id.ID, messageID cryptoChannel.MessageID, - myUsername string, text string, timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - -func (m *mockEventModel) ReplySent(channelID *id.ID, messageID cryptoChannel.MessageID, - replyTo cryptoChannel.MessageID, myUsername string, text string, - timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - -func (m *mockEventModel) ReactionSent(channelID *id.ID, messageID cryptoChannel.MessageID, - reactionTo cryptoChannel.MessageID, senderUsername string, reaction string, - timestamp time.Time, lease time.Duration, round rounds.Round) { - //TODO implement me - panic("implement me") -} - func (m *mockEventModel) UpdateSentStatus(messageID cryptoChannel.MessageID, status SentStatus) { //TODO implement me @@ -537,13 +517,13 @@ func (m *mockEventModel) LeaveChannel(c *id.ID) { m.leftCh = c } func (m *mockEventModel) ReceiveMessage(*id.ID, cryptoChannel.MessageID, string, - string, time.Time, time.Duration, rounds.Round) { + string, time.Time, time.Duration, rounds.Round, SentStatus) { } func (m *mockEventModel) ReceiveReply(*id.ID, cryptoChannel.MessageID, cryptoChannel.MessageID, string, string, time.Time, time.Duration, - rounds.Round) { + rounds.Round, SentStatus) { } func (m *mockEventModel) ReceiveReaction(*id.ID, cryptoChannel.MessageID, cryptoChannel.MessageID, string, string, time.Time, time.Duration, - rounds.Round) { + rounds.Round, SentStatus) { }