Skip to content
Snippets Groups Projects
Commit 6aee1d39 authored by Jono Wenger's avatar Jono Wenger
Browse files

Fix bindings

parent b3753574
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...,!413Xx 4263,!340Project/channels
......@@ -8,9 +8,9 @@
package bindings
import (
"crypto/ed25519"
"encoding/json"
"github.com/pkg/errors"
jww "github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/client/channels"
"gitlab.com/elixxir/client/cmix/rounds"
"gitlab.com/elixxir/client/storage/versioned"
......@@ -913,7 +913,8 @@ type ReceivedChannelMessageReport struct {
MessageId []byte
MessageType int
Nickname string
Identity []byte
PubKey []byte
Codeset int
Content []byte
Timestamp int64
Lease int64
......@@ -947,22 +948,17 @@ func (cm *ChannelsManager) RegisterReceiveHandler(messageType int,
cb := channels.MessageTypeReceiveMessage(
func(channelID *id.ID,
messageID cryptoChannel.MessageID, messageType channels.MessageType,
nickname string, content []byte, identity cryptoChannel.Identity,
timestamp time.Time, lease time.Duration, round rounds.Round,
status channels.SentStatus) uint64 {
idBytes, err := json.Marshal(&identity)
if err != nil {
jww.WARN.Printf("failed to marshal identity object: %+v", err)
return 0
}
nickname string, content []byte, pubKey ed25519.PublicKey,
codeset uint8, timestamp time.Time, lease time.Duration,
round rounds.Round, status channels.SentStatus) uint64 {
rcm := ReceivedChannelMessageReport{
ChannelId: channelID.Marshal(),
MessageId: messageID.Bytes(),
MessageType: int(messageType),
Nickname: nickname,
Identity: idBytes,
PubKey: pubKey,
Codeset: int(codeset),
Content: content,
Timestamp: timestamp.UnixNano(),
Lease: int64(lease),
......@@ -1013,7 +1009,8 @@ type EventModel interface {
// - text - The content of the message.
// - timestamp - Time the message was received; represented as nanoseconds
// since unix epoch.
// - identity - the json of the identity of the sender
// - pubKey - The sender's Ed25519 public key.
// - codeset - The codeset version.
// - lease - The number of nanoseconds that the message is valid for.
// - roundId - The ID of the round that the message was received on.
// - mType - the type of the message, always 1 for this call
......@@ -1027,7 +1024,7 @@ type EventModel interface {
// Returns a non-negative unique UUID for the message that it can be
// referenced by later with [EventModel.UpdateSentStatus].
ReceiveMessage(channelID, messageID []byte, nickname, text string,
identity []byte, timestamp, lease, roundId, mType,
pubKey []byte, codeset int, timestamp, lease, roundId, mType,
status int64) int64
// ReceiveReply is called whenever a message is received that is a reply on
......@@ -1045,7 +1042,8 @@ type EventModel interface {
// reply.
// - nickname - The nickname of the sender of the message.
// - text - The content of the message.
// - identity - the json marshaled identity of the sender
// - pubKey - The sender's Ed25519 public key.
// - codeset - The codeset version.
// - timestamp - Time the message was received; represented as nanoseconds
// since unix epoch.
// - lease - The number of nanoseconds that the message is valid for.
......@@ -1060,9 +1058,9 @@ type EventModel interface {
//
// Returns a non-negative unique UUID for the message that it can be
// referenced by later with [EventModel.UpdateSentStatus].
ReceiveReply(channelID, messageID, reactionTo []byte,
nickname, text string, identity []byte,
timestamp, lease, roundId, mType, status int64) int64
ReceiveReply(channelID, messageID, reactionTo []byte, nickname, text string,
pubKey []byte, codeset int, timestamp, lease, roundId, mType,
status int64) int64
// 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.
......@@ -1081,7 +1079,8 @@ type EventModel interface {
// reply.
// - nickname - The nickname of the sender of the message.
// - reaction - The contents of the reaction message.
// - identity - The json marshal of the identity of the sender
// - pubKey - The sender's Ed25519 public key.
// - codeset - The codeset version.
// - timestamp - Time the message was received; represented as nanoseconds
// since unix epoch.
// - lease - The number of nanoseconds that the message is valid for.
......@@ -1096,9 +1095,9 @@ type EventModel interface {
//
// Returns a non-negative unique uuid for the message by which it can be
// referenced later with UpdateSentStatus
ReceiveReaction(channelID, messageID, reactionTo []byte,
nickname, reaction string, identity []byte,
timestamp, lease, roundId, mtype, status int64) int64
ReceiveReaction(channelID, messageID, reactionTo []byte, nickname,
reaction string, pubKey []byte, codeset int, timestamp, lease, roundId,
mType, status int64) int64
// UpdateSentStatus is called whenever the sent status of a message has
// changed.
......@@ -1146,21 +1145,15 @@ func (tem *toEventModel) LeaveChannel(channelID *id.ID) {
// ReceiveMessage is called whenever a message is received on a given channel.
// 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.
func (tem *toEventModel) ReceiveMessage(channelID *id.ID, messageID cryptoChannel.MessageID,
nickname, text string, identity cryptoChannel.Identity,
timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType,
func (tem *toEventModel) ReceiveMessage(channelID *id.ID,
messageID cryptoChannel.MessageID, nickname, text string,
pubKey ed25519.PublicKey, codeset uint8, timestamp time.Time,
lease time.Duration, round rounds.Round, mType channels.MessageType,
status channels.SentStatus) uint64 {
idBytes, err := json.Marshal(&identity)
if err != nil {
jww.WARN.Printf("failed to marshal identity object: %+v", err)
return 0
}
return uint64(tem.em.ReceiveMessage(channelID[:], messageID[:], nickname,
text, idBytes, timestamp.UnixNano(), int64(lease), int64(round.ID), int64(mType),
int64(status)))
text, pubKey, int(codeset), timestamp.UnixNano(), int64(lease),
int64(round.ID), int64(mType), int64(status)))
}
// ReceiveReply is called whenever a message is received that is a reply on a
......@@ -1169,21 +1162,15 @@ func (tem *toEventModel) ReceiveMessage(channelID *id.ID, messageID cryptoChanne
//
// Messages may arrive our of order, so a reply in theory can arrive before the
// initial message. As a result, it may be important to buffer replies.
func (tem *toEventModel) 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, mType channels.MessageType,
status channels.SentStatus) uint64 {
idBytes, err := json.Marshal(&identity)
if err != nil {
jww.WARN.Printf("failed to marshal identity object: %+v", err)
return 0
}
func (tem *toEventModel) ReceiveReply(channelID *id.ID,
messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID,
nickname, text string, pubKey ed25519.PublicKey, codeset uint8,
timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType, status channels.SentStatus) uint64 {
return uint64(tem.em.ReceiveReply(channelID[:], messageID[:], reactionTo[:],
nickname, text, idBytes, timestamp.UnixNano(), int64(lease),
int64(round.ID), int64(mType), int64(status)))
nickname, text, pubKey, int(codeset), timestamp.UnixNano(),
int64(lease), int64(round.ID), int64(mType), int64(status)))
}
......@@ -1195,19 +1182,14 @@ func (tem *toEventModel) ReceiveReply(channelID *id.ID, messageID cryptoChannel.
// initial message. As a result, it may be important to buffer reactions.
func (tem *toEventModel) ReceiveReaction(channelID *id.ID, messageID cryptoChannel.MessageID,
reactionTo cryptoChannel.MessageID, nickname, reaction string,
identity cryptoChannel.Identity, timestamp time.Time,
pubKey ed25519.PublicKey, codeset uint8, timestamp time.Time,
lease time.Duration, round rounds.Round, mType channels.MessageType,
status channels.SentStatus) uint64 {
idBytes, err := json.Marshal(&identity)
if err != nil {
jww.WARN.Printf("failed to marshal identity object: %+v", err)
return 0
}
return uint64(tem.em.ReceiveReaction(channelID[:], messageID[:],
reactionTo[:], nickname, reaction, idBytes, timestamp.UnixNano(),
int64(lease), int64(round.ID), int64(mType), int64(status)))
reactionTo[:], nickname, reaction, pubKey, int(codeset),
timestamp.UnixNano(), int64(lease), int64(round.ID), int64(mType),
int64(status)))
}
// UpdateSentStatus is called whenever the sent status of a message has changed.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment