Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xxdk-wasm
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
xxdk-wasm
Commits
9ec9c60c
Commit
9ec9c60c
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Patches
Plain Diff
make text field into bytes
parent
020a97c5
No related branches found
No related tags found
1 merge request
!60
Revert "Fail a test to be sure it works"
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
indexedDb/implementation.go
+9
-8
9 additions, 8 deletions
indexedDb/implementation.go
indexedDb/implementation_test.go
+3
-3
3 additions, 3 deletions
indexedDb/implementation_test.go
indexedDb/model.go
+1
-1
1 addition, 1 deletion
indexedDb/model.go
with
13 additions
and
12 deletions
indexedDb/implementation.go
+
9
−
8
View file @
9ec9c60c
...
...
@@ -206,20 +206,21 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
pubKey
ed25519
.
PublicKey
,
codeset
uint8
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
,
mType
channels
.
MessageType
,
status
channels
.
SentStatus
)
uint64
{
textBytes
:=
[]
byte
(
text
)
var
err
error
// Handle encryption, if it is present
if
w
.
cipher
!=
nil
{
cipherText
,
err
:
=
w
.
cipher
.
Encrypt
([]
byte
(
text
))
textBytes
,
err
=
w
.
cipher
.
Encrypt
([]
byte
(
text
))
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to encrypt Message: %+v"
,
err
)
return
0
}
text
=
string
(
cipherText
)
}
msgToInsert
:=
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
nil
,
nickname
,
text
,
pubKey
,
codeset
,
timestamp
,
lease
,
round
.
ID
,
mType
,
status
)
channelID
.
Marshal
(),
messageID
.
Bytes
(),
nil
,
nickname
,
textBytes
,
pubKey
,
codeset
,
timestamp
,
lease
,
round
.
ID
,
mType
,
status
)
uuid
,
err
:=
w
.
receiveHelper
(
msgToInsert
,
false
)
if
err
!=
nil
{
...
...
@@ -243,7 +244,7 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID,
mType
channels
.
MessageType
,
status
channels
.
SentStatus
)
uint64
{
msgToInsert
:=
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
replyTo
.
Bytes
(),
nickname
,
text
,
pubKey
,
codeset
,
timestamp
,
lease
,
replyTo
.
Bytes
(),
nickname
,
[]
byte
(
text
)
,
pubKey
,
codeset
,
timestamp
,
lease
,
round
.
ID
,
mType
,
status
)
uuid
,
err
:=
w
.
receiveHelper
(
msgToInsert
,
false
)
...
...
@@ -269,7 +270,7 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID,
msgToInsert
:=
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
reactionTo
.
Bytes
(),
nickname
,
reaction
,
pubKey
,
codeset
,
timestamp
,
lease
,
round
.
ID
,
mType
,
status
)
[]
byte
(
reaction
)
,
pubKey
,
codeset
,
timestamp
,
lease
,
round
.
ID
,
mType
,
status
)
uuid
,
err
:=
w
.
receiveHelper
(
msgToInsert
,
false
)
if
err
!=
nil
{
...
...
@@ -339,8 +340,8 @@ func (w *wasmModel) UpdateSentStatus(uuid uint64,
// NOTE: ID is not set inside this function because we want to use the
// autoincrement key by default. If you are trying to overwrite an existing
// message, then you need to set it manually yourself.
func
buildMessage
(
channelID
,
messageID
,
parentID
[]
byte
,
nickname
,
text
string
,
pubKey
ed25519
.
PublicKey
,
codeset
uint8
,
timestamp
time
.
Time
,
func
buildMessage
(
channelID
,
messageID
,
parentID
[]
byte
,
nickname
string
,
text
[]
byte
,
pubKey
ed25519
.
PublicKey
,
codeset
uint8
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
id
.
Round
,
mType
channels
.
MessageType
,
status
channels
.
SentStatus
)
*
Message
{
return
&
Message
{
...
...
This diff is collapsed.
Click to expand it.
indexedDb/implementation_test.go
+
3
−
3
View file @
9ec9c60c
...
...
@@ -46,7 +46,7 @@ func Test_wasmModel_UpdateSentStatus(t *testing.T) {
// Store a test message
testMsg
:=
buildMessage
([]
byte
(
testString
),
testMsgId
.
Bytes
(),
nil
,
testString
,
testString
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
testString
,
[]
byte
(
testString
)
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
time
.
Second
,
0
,
0
,
channels
.
Sent
)
uuid
,
err
:=
eventModel
.
receiveHelper
(
testMsg
,
false
)
if
err
!=
nil
{
...
...
@@ -285,7 +285,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
// First message insert should succeed
testMsgId
:=
channel
.
MakeMessageID
([]
byte
(
testString
),
&
id
.
ID
{
1
})
testMsg
:=
buildMessage
([]
byte
(
testString
),
testMsgId
.
Bytes
(),
nil
,
testString
,
testString
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
testString
,
[]
byte
(
testString
)
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
time
.
Second
,
0
,
0
,
channels
.
Sent
)
_
,
err
=
eventModel
.
receiveHelper
(
testMsg
,
false
)
if
err
!=
nil
{
...
...
@@ -308,7 +308,7 @@ func TestWasmModel_receiveHelper_UniqueIndex(t *testing.T) {
// Now insert a message with a different message ID from the first
testMsgId2
:=
channel
.
MakeMessageID
([]
byte
(
testString
),
&
id
.
ID
{
2
})
testMsg
=
buildMessage
([]
byte
(
testString
),
testMsgId2
.
Bytes
(),
nil
,
testString
,
testString
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
testString
,
[]
byte
(
testString
)
,
[]
byte
{
8
,
6
,
7
,
5
},
0
,
netTime
.
Now
(),
time
.
Second
,
0
,
0
,
channels
.
Sent
)
primaryKey
,
err
:=
eventModel
.
receiveHelper
(
testMsg
,
false
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
indexedDb/model.go
+
1
−
1
View file @
9ec9c60c
...
...
@@ -55,7 +55,7 @@ type Message struct {
Status
uint8
`json:"status"`
Hidden
bool
`json:"hidden"`
Pinned
bool
`json:"pinned"`
// Index
Text
string
`json:"text"`
Text
[]
byte
`json:"text"`
Type
uint16
`json:"type"`
Round
uint64
`json:"round"`
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment