Skip to content
Snippets Groups Projects
Commit 0d30d4eb authored by Jake Taylor's avatar Jake Taylor
Browse files

add DM field to indexedDb Message object

parent 9dc8d106
No related branches found
No related tags found
3 merge requests!60Revert "Fail a test to be sure it works",!36project/DM,!32Admin Commands
...@@ -7,15 +7,16 @@ require ( ...@@ -7,15 +7,16 @@ require (
github.com/hack-pad/go-indexeddb v0.2.0 github.com/hack-pad/go-indexeddb v0.2.0
github.com/pkg/errors v0.9.1 github.com/pkg/errors v0.9.1
github.com/spf13/jwalterweatherman v1.1.0 github.com/spf13/jwalterweatherman v1.1.0
gitlab.com/elixxir/client/v4 v4.3.6 gitlab.com/elixxir/client/v4 v4.3.9-0.20221116223541-2febb84c7792
gitlab.com/elixxir/crypto v0.0.7-0.20221110181326-dd7e5293feb0 gitlab.com/elixxir/crypto v0.0.7-0.20221116220932-3e3f8c161e4d
gitlab.com/elixxir/primitives v0.0.3-0.20221110181119-e83320a48b13 gitlab.com/elixxir/primitives v0.0.3-0.20221114231218-cc461261a6af
gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95 gitlab.com/xx_network/crypto v0.0.5-0.20221110181048-76f0c556fe95
gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225 gitlab.com/xx_network/primitives v0.0.4-0.20221110180011-fd6ea3058225
golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa golang.org/x/crypto v0.0.0-20220722155217-630584e8d5aa
) )
require ( require (
filippo.io/edwards25519 v1.0.0 // indirect
git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221102223039-dc1f37d94e70 // indirect git.xx.network/elixxir/grpc-web-go-client v0.0.0-20221102223039-dc1f37d94e70 // indirect
github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect github.com/andres-erbsen/clock v0.0.0-20160526145045-9e14626cd129 // indirect
github.com/badoux/checkmail v1.2.1 // indirect github.com/badoux/checkmail v1.2.1 // indirect
...@@ -23,20 +24,36 @@ require ( ...@@ -23,20 +24,36 @@ require (
github.com/cloudflare/circl v1.2.0 // indirect github.com/cloudflare/circl v1.2.0 // indirect
github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect github.com/desertbit/timer v0.0.0-20180107155436-c41aec40b27f // indirect
github.com/elliotchance/orderedmap v1.4.0 // indirect github.com/elliotchance/orderedmap v1.4.0 // indirect
github.com/fsnotify/fsnotify v1.5.4 // indirect
github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect github.com/golang-collections/collections v0.0.0-20130729185459-604e922904d3 // indirect
github.com/golang/protobuf v1.5.2 // indirect github.com/golang/protobuf v1.5.2 // indirect
github.com/gorilla/websocket v1.5.0 // indirect github.com/gorilla/websocket v1.5.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/improbable-eng/grpc-web v0.15.0 // indirect github.com/improbable-eng/grpc-web v0.15.0 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect github.com/json-iterator/go v1.1.12 // indirect
github.com/klauspost/compress v1.11.7 // indirect github.com/klauspost/compress v1.11.7 // indirect
github.com/klauspost/cpuid/v2 v2.1.0 // indirect github.com/klauspost/cpuid/v2 v2.1.0 // indirect
github.com/magiconair/properties v1.8.6 // indirect
github.com/mattn/go-isatty v0.0.14 // indirect github.com/mattn/go-isatty v0.0.14 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect github.com/nfnt/resize v0.0.0-20180221191011-83c6a9932646 // indirect
github.com/oasisprotocol/curve25519-voi v0.0.0-20221003100820-41fad3beba17 // indirect
github.com/oasisprotocol/deoxysii v0.0.0-20220228165953-2091330c22b7 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/pelletier/go-toml/v2 v2.0.2 // indirect
github.com/pkg/profile v1.6.0 // indirect
github.com/rs/cors v1.8.2 // indirect github.com/rs/cors v1.8.2 // indirect
github.com/sethvargo/go-diceware v0.3.0 // indirect github.com/sethvargo/go-diceware v0.3.0 // indirect
github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect github.com/skip2/go-qrcode v0.0.0-20200617195104-da1b6568686e // indirect
github.com/soheilhy/cmux v0.1.5 // indirect github.com/soheilhy/cmux v0.1.5 // indirect
github.com/spf13/afero v1.9.2 // indirect
github.com/spf13/cast v1.5.0 // indirect
github.com/spf13/cobra v1.5.0 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/spf13/viper v1.12.0 // indirect
github.com/subosito/gotenv v1.4.0 // indirect
github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect github.com/ttacon/builder v0.0.0-20170518171403-c099f663e1c2 // indirect
github.com/ttacon/libphonenumber v1.2.1 // indirect github.com/ttacon/libphonenumber v1.2.1 // indirect
github.com/tyler-smith/go-bip39 v1.1.0 // indirect github.com/tyler-smith/go-bip39 v1.1.0 // indirect
...@@ -46,13 +63,19 @@ require ( ...@@ -46,13 +63,19 @@ require (
gitlab.com/elixxir/ekv v0.2.1 // indirect gitlab.com/elixxir/ekv v0.2.1 // indirect
gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936 // indirect gitlab.com/xx_network/comms v0.0.4-0.20221110181111-4f0694876936 // indirect
gitlab.com/xx_network/ring v0.0.3-0.20220902183151-a7d3b15bc981 // indirect gitlab.com/xx_network/ring v0.0.3-0.20220902183151-a7d3b15bc981 // indirect
gitlab.com/yawning/bsaes.git v0.0.0-20190805113838-0a714cd429ec // indirect
gitlab.com/yawning/nyquist.git v0.0.0-20221003103146-de5645224a22 // indirect
gitlab.com/yawning/x448.git v0.0.0-20221003101044-617eb9b7d9b7 // indirect
go.uber.org/atomic v1.10.0 // indirect go.uber.org/atomic v1.10.0 // indirect
go.uber.org/ratelimit v0.2.0 // indirect go.uber.org/ratelimit v0.2.0 // indirect
golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect golang.org/x/net v0.0.0-20220822230855-b0a4917ee28c // indirect
golang.org/x/sys v0.0.0-20220731174439-a90be440212d // indirect golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
golang.org/x/text v0.3.7 // indirect golang.org/x/text v0.3.7 // indirect
google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc // indirect
google.golang.org/grpc v1.49.0 // indirect google.golang.org/grpc v1.49.0 // indirect
google.golang.org/protobuf v1.28.1 // indirect google.golang.org/protobuf v1.28.1 // indirect
gopkg.in/ini.v1 v1.66.6 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
nhooyr.io/websocket v1.8.7 // indirect nhooyr.io/websocket v1.8.7 // indirect
) )
This diff is collapsed.
...@@ -203,7 +203,7 @@ func (w *wasmModel) deleteMsgByChannel(channelID *id.ID) error { ...@@ -203,7 +203,7 @@ func (w *wasmModel) deleteMsgByChannel(channelID *id.ID) error {
// user of the API to filter such called by message ID. // user of the API to filter such called by message ID.
func (w *wasmModel) ReceiveMessage(channelID *id.ID, func (w *wasmModel) ReceiveMessage(channelID *id.ID,
messageID cryptoChannel.MessageID, nickname, text string, messageID cryptoChannel.MessageID, nickname, text string,
pubKey ed25519.PublicKey, codeset uint8, pubKey ed25519.PublicKey, dmToken []byte, codeset uint8,
timestamp time.Time, lease time.Duration, round rounds.Round, timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType, status channels.SentStatus) uint64 { mType channels.MessageType, status channels.SentStatus) uint64 {
textBytes := []byte(text) textBytes := []byte(text)
...@@ -220,7 +220,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, ...@@ -220,7 +220,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
msgToInsert := buildMessage( msgToInsert := buildMessage(
channelID.Marshal(), messageID.Bytes(), nil, nickname, channelID.Marshal(), messageID.Bytes(), nil, nickname,
textBytes, pubKey, codeset, timestamp, lease, round.ID, mType, status) textBytes, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType, status)
uuid, err := w.receiveHelper(msgToInsert, false) uuid, err := w.receiveHelper(msgToInsert, false)
if err != nil { if err != nil {
...@@ -239,7 +239,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID, ...@@ -239,7 +239,7 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
// the initial message. As a result, it may be important to buffer replies. // the initial message. As a result, it may be important to buffer replies.
func (w *wasmModel) ReceiveReply(channelID *id.ID, func (w *wasmModel) ReceiveReply(channelID *id.ID,
messageID cryptoChannel.MessageID, replyTo cryptoChannel.MessageID, messageID cryptoChannel.MessageID, replyTo cryptoChannel.MessageID,
nickname, text string, pubKey ed25519.PublicKey, codeset uint8, nickname, text string, pubKey ed25519.PublicKey, dmToken []byte, codeset uint8,
timestamp time.Time, lease time.Duration, round rounds.Round, timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType, status channels.SentStatus) uint64 { mType channels.MessageType, status channels.SentStatus) uint64 {
textBytes := []byte(text) textBytes := []byte(text)
...@@ -255,8 +255,8 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, ...@@ -255,8 +255,8 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID,
} }
msgToInsert := buildMessage(channelID.Marshal(), messageID.Bytes(), msgToInsert := buildMessage(channelID.Marshal(), messageID.Bytes(),
replyTo.Bytes(), nickname, textBytes, pubKey, codeset, timestamp, lease, replyTo.Bytes(), nickname, textBytes, pubKey, dmToken, codeset,
round.ID, mType, status) timestamp, lease, round.ID, mType, status)
uuid, err := w.receiveHelper(msgToInsert, false) uuid, err := w.receiveHelper(msgToInsert, false)
...@@ -275,7 +275,7 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID, ...@@ -275,7 +275,7 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID,
// the initial message. As a result, it may be important to buffer reactions. // the initial message. As a result, it may be important to buffer reactions.
func (w *wasmModel) ReceiveReaction(channelID *id.ID, func (w *wasmModel) ReceiveReaction(channelID *id.ID,
messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID, messageID cryptoChannel.MessageID, reactionTo cryptoChannel.MessageID,
nickname, reaction string, pubKey ed25519.PublicKey, codeset uint8, nickname, reaction string, pubKey ed25519.PublicKey, dmToken []byte, codeset uint8,
timestamp time.Time, lease time.Duration, round rounds.Round, timestamp time.Time, lease time.Duration, round rounds.Round,
mType channels.MessageType, status channels.SentStatus) uint64 { mType channels.MessageType, status channels.SentStatus) uint64 {
textBytes := []byte(reaction) textBytes := []byte(reaction)
...@@ -292,7 +292,7 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID, ...@@ -292,7 +292,7 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID,
msgToInsert := buildMessage( msgToInsert := buildMessage(
channelID.Marshal(), messageID.Bytes(), reactionTo.Bytes(), nickname, channelID.Marshal(), messageID.Bytes(), reactionTo.Bytes(), nickname,
textBytes, pubKey, codeset, timestamp, lease, round.ID, mType, status) textBytes, pubKey, dmToken, codeset, timestamp, lease, round.ID, mType, status)
uuid, err := w.receiveHelper(msgToInsert, false) uuid, err := w.receiveHelper(msgToInsert, false)
if err != nil { if err != nil {
...@@ -363,7 +363,7 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64, ...@@ -363,7 +363,7 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64,
// autoincrement key by default. If you are trying to overwrite an existing // autoincrement key by default. If you are trying to overwrite an existing
// message, then you need to set it manually yourself. // message, then you need to set it manually yourself.
func buildMessage(channelID, messageID, parentID []byte, nickname string, func buildMessage(channelID, messageID, parentID []byte, nickname string,
text []byte, pubKey ed25519.PublicKey, codeset uint8, timestamp time.Time, text []byte, pubKey ed25519.PublicKey, dmToken []byte, codeset uint8, timestamp time.Time,
lease time.Duration, round id.Round, mType channels.MessageType, lease time.Duration, round id.Round, mType channels.MessageType,
status channels.SentStatus) *Message { status channels.SentStatus) *Message {
return &Message{ return &Message{
...@@ -381,6 +381,7 @@ func buildMessage(channelID, messageID, parentID []byte, nickname string, ...@@ -381,6 +381,7 @@ func buildMessage(channelID, messageID, parentID []byte, nickname string,
Round: uint64(round), Round: uint64(round),
// User Identity Info // User Identity Info
Pubkey: pubKey, Pubkey: pubKey,
DmToken: dmToken,
CodesetVersion: codeset, CodesetVersion: codeset,
} }
} }
......
...@@ -46,7 +46,7 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) { ...@@ -46,7 +46,7 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) {
// Store a test message // Store a test message
testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil, testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, netTime.Now(), testString, []byte(testString), []byte{8, 6, 7, 5}, nil, 0, netTime.Now(),
time.Second, 0, 0, channels.Sent) time.Second, 0, 0, channels.Sent)
uuid, err := eventModel.receiveHelper(testMsg, false) uuid, err := eventModel.receiveHelper(testMsg, false)
if err != nil { if err != nil {
...@@ -146,7 +146,7 @@ func Test_wasmModel_UUIDTest(t *testing.T) { ...@@ -146,7 +146,7 @@ func Test_wasmModel_UUIDTest(t *testing.T) {
copy(msgID[:], testString+fmt.Sprintf("%d", i)) copy(msgID[:], testString+fmt.Sprintf("%d", i))
rnd := rounds.Round{ID: id.Round(42)} rnd := rounds.Round{ID: id.Round(42)}
uuid := eventModel.ReceiveMessage(channelID, msgID, "test", uuid := eventModel.ReceiveMessage(channelID, msgID, "test",
testString+fmt.Sprintf("%d", i), []byte{8, 6, 7, 5}, 0, testString+fmt.Sprintf("%d", i), []byte{8, 6, 7, 5}, nil, 0,
netTime.Now(), time.Hour, rnd, 0, channels.Sent) netTime.Now(), time.Hour, rnd, 0, channels.Sent)
uuids[i] = uuid uuids[i] = uuid
} }
...@@ -181,7 +181,7 @@ func Test_wasmModel_DuplicateReceives(t *testing.T) { ...@@ -181,7 +181,7 @@ func Test_wasmModel_DuplicateReceives(t *testing.T) {
channelID := id.NewIdFromBytes([]byte(testString), t) channelID := id.NewIdFromBytes([]byte(testString), t)
rnd := rounds.Round{ID: id.Round(42)} rnd := rounds.Round{ID: id.Round(42)}
uuid := eventModel.ReceiveMessage(channelID, msgID, "test", uuid := eventModel.ReceiveMessage(channelID, msgID, "test",
testString+fmt.Sprintf("%d", i), []byte{8, 6, 7, 5}, 0, testString+fmt.Sprintf("%d", i), []byte{8, 6, 7, 5}, nil, 0,
netTime.Now(), time.Hour, rnd, 0, channels.Sent) netTime.Now(), time.Hour, rnd, 0, channels.Sent)
uuids[i] = uuid uuids[i] = uuid
} }
...@@ -225,7 +225,7 @@ func Test_wasmModel_deleteMsgByChannel(t *testing.T) { ...@@ -225,7 +225,7 @@ func Test_wasmModel_deleteMsgByChannel(t *testing.T) {
testMsgId := channel.MakeMessageID([]byte(testStr), &id.ID{1}) testMsgId := channel.MakeMessageID([]byte(testStr), &id.ID{1})
eventModel.ReceiveMessage(thisChannel, testMsgId, testStr, testStr, eventModel.ReceiveMessage(thisChannel, testMsgId, testStr, testStr,
[]byte{8, 6, 7, 5}, 0, netTime.Now(), time.Second, []byte{8, 6, 7, 5}, nil, 0, netTime.Now(), time.Second,
rounds.Round{ID: id.Round(0)}, 0, channels.Sent) rounds.Round{ID: id.Round(0)}, 0, channels.Sent)
} }
...@@ -285,7 +285,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) { ...@@ -285,7 +285,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
// First message insert should succeed // First message insert should succeed
testMsgId := channel.MakeMessageID([]byte(testString), &id.ID{1}) testMsgId := channel.MakeMessageID([]byte(testString), &id.ID{1})
testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil, testMsg := buildMessage([]byte(testString), testMsgId.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, netTime.Now(), testString, []byte(testString), []byte{8, 6, 7, 5}, nil, 0, netTime.Now(),
time.Second, 0, 0, channels.Sent) time.Second, 0, 0, channels.Sent)
_, err = eventModel.receiveHelper(testMsg, false) _, err = eventModel.receiveHelper(testMsg, false)
if err != nil { if err != nil {
...@@ -308,7 +308,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) { ...@@ -308,7 +308,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
// Now insert a message with a different message ID from the first // Now insert a message with a different message ID from the first
testMsgId2 := channel.MakeMessageID([]byte(testString), &id.ID{2}) testMsgId2 := channel.MakeMessageID([]byte(testString), &id.ID{2})
testMsg = buildMessage([]byte(testString), testMsgId2.Bytes(), nil, testMsg = buildMessage([]byte(testString), testMsgId2.Bytes(), nil,
testString, []byte(testString), []byte{8, 6, 7, 5}, 0, netTime.Now(), testString, []byte(testString), []byte{8, 6, 7, 5}, nil, 0, netTime.Now(),
time.Second, 0, 0, channels.Sent) time.Second, 0, 0, channels.Sent)
primaryKey, err := eventModel.receiveHelper(testMsg, false) primaryKey, err := eventModel.receiveHelper(testMsg, false)
if err != nil { if err != nil {
......
...@@ -60,7 +60,8 @@ type Message struct { ...@@ -60,7 +60,8 @@ type Message struct {
Round uint64 `json:"round"` Round uint64 `json:"round"`
// User cryptographic Identity struct -- could be pulled out // User cryptographic Identity struct -- could be pulled out
Pubkey []byte `json:"pubkey"` // Index Pubkey []byte `json:"pubkey"` // Index
DmToken []byte `json:"dm_token"` // Index
CodesetVersion uint8 `json:"codeset_version"` CodesetVersion uint8 `json:"codeset_version"`
} }
......
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