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
b274d09f
Commit
b274d09f
authored
2 years ago
by
Richard T. Carback III
Committed by
Jono Wenger
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Update implementation to insert the user identity to each message
parent
f40f71c7
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!60
Revert "Fail a test to be sure it works"
,
!8
Updates to match the client fullyDecentrilizedChannels branch
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
indexedDb/implementation.go
+38
-22
38 additions, 22 deletions
indexedDb/implementation.go
with
38 additions
and
22 deletions
indexedDb/implementation.go
+
38
−
22
View file @
b274d09f
...
...
@@ -13,12 +13,13 @@ import (
"context"
"encoding/base64"
"encoding/json"
"syscall/js"
"time"
"github.com/hack-pad/go-indexeddb/idb"
"github.com/pkg/errors"
jww
"github.com/spf13/jwalterweatherman"
"gitlab.com/elixxir/xxdk-wasm/utils"
"syscall/js"
"time"
"gitlab.com/elixxir/client/channels"
"gitlab.com/elixxir/client/cmix/rounds"
...
...
@@ -145,13 +146,15 @@ func (w *wasmModel) LeaveChannel(channelID *id.ID) {
// 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
(
w
*
wasmModel
)
ReceiveMessage
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
senderUsername
string
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
_
rounds
.
Round
,
messageID
cryptoChannel
.
MessageID
,
nickname
,
text
string
,
identity
cryptoChannel
.
Identity
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
,
status
channels
.
SentStatus
)
{
parentErr
:=
errors
.
New
(
"failed to ReceiveMessage"
)
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
nil
,
senderUsername
,
text
,
timestamp
,
lease
,
status
))
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
nil
,
nickname
,
text
,
identity
,
timestamp
,
lease
,
status
))
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"%+v"
,
errors
.
Wrap
(
parentErr
,
err
.
Error
()))
}
...
...
@@ -164,13 +167,15 @@ func (w *wasmModel) ReceiveMessage(channelID *id.ID,
// 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
(
w
*
wasmModel
)
ReceiveReply
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
replyTo
cryptoChannel
.
MessageID
,
senderUsername
string
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
_
rounds
.
Round
,
status
channels
.
SentStatus
)
{
messageID
cryptoChannel
.
MessageID
,
reactionTo
cryptoChannel
.
MessageID
,
nickname
,
text
string
,
identity
cryptoChannel
.
Identity
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
,
status
SentStatus
)
uint64
{
parentErr
:=
errors
.
New
(
"failed to ReceiveReply"
)
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
replyTo
.
Bytes
(),
senderUsername
,
text
,
timestamp
,
lease
,
status
))
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
replyTo
.
Bytes
(),
nickname
,
text
,
identity
,
timestamp
,
lease
,
status
))
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"%+v"
,
errors
.
Wrap
(
parentErr
,
err
.
Error
()))
}
...
...
@@ -182,14 +187,15 @@ func (w *wasmModel) ReceiveReply(channelID *id.ID,
//
// 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 reactions.
func
(
w
*
wasmModel
)
ReceiveReaction
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
reactionTo
cryptoChannel
.
MessageID
,
senderUsername
string
,
reaction
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
_
rounds
.
Round
,
status
channels
.
SentStatus
)
{
func
(
w
*
wasmModel
)
ReceiveReaction
(
channelID
*
id
.
ID
,
messageID
cryptoChannel
.
MessageID
,
reactionTo
cryptoChannel
.
MessageID
,
nickname
,
reaction
string
,
identity
cryptoChannel
.
Identity
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
,
status
SentStatus
)
uint64
{
parentErr
:=
errors
.
New
(
"failed to ReceiveReaction"
)
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
reactionTo
.
Bytes
(),
senderUsername
,
reaction
,
timestamp
,
lease
,
status
))
err
:=
w
.
receiveHelper
(
buildMessage
(
channelID
.
Marshal
(),
messageID
.
Bytes
(),
reactionTo
.
Bytes
(),
nickname
,
reaction
,
identity
,
timestamp
,
lease
,
status
))
if
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"%+v"
,
errors
.
Wrap
(
parentErr
,
err
.
Error
()))
}
...
...
@@ -198,8 +204,8 @@ func (w *wasmModel) ReceiveReaction(channelID *id.ID,
// UpdateSentStatus is called whenever the [channels.SentStatus] of a message
// has changed.
// TODO: Potential race condition due to separate get/update operations.
func
(
w
*
wasmModel
)
UpdateSentStatus
(
messageID
cryptoChannel
.
MessageID
,
status
channels
.
SentStatus
)
{
func
(
w
*
wasmModel
)
UpdateSentStatus
(
uuid
uint64
,
messageID
cryptoChannel
.
MessageID
,
timestamp
time
.
Time
,
round
rounds
.
Round
,
status
SentStatus
)
{
parentErr
:=
errors
.
New
(
"failed to UpdateSentStatus"
)
// Convert messageID to the key generated by json.Marshal
...
...
@@ -228,12 +234,13 @@ func (w *wasmModel) UpdateSentStatus(messageID cryptoChannel.MessageID,
// buildMessage is a private helper that converts typical [channels.EventModel]
// inputs into a basic Message structure for insertion into storage.
func
buildMessage
(
channelID
,
messageID
,
parentId
[]
byte
,
senderUsername
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
func
buildMessage
(
channelID
,
messageID
,
parentId
[]
byte
,
nickname
,
text
string
,
timestamp
time
.
Time
,
identity
cryptoChannel
.
Identity
,
lease
time
.
Duration
,
status
channels
.
SentStatus
)
*
Message
{
return
&
Message
{
Id
:
messageID
,
SenderUsername
:
senderUser
name
,
Nickname
:
nick
name
,
ChannelId
:
channelID
,
ParentMessageId
:
parentId
,
Timestamp
:
timestamp
,
...
...
@@ -242,6 +249,15 @@ func buildMessage(channelID, messageID, parentId []byte, senderUsername,
Hidden
:
false
,
Pinned
:
false
,
Text
:
text
,
// User Identity Info
Pubkey
:
identity
.
PubKey
.
Bytes
(),
Honorific
:
identity
.
Honorific
.
String
(),
Adjective
:
identity
.
Adjective
.
String
(),
Noun
:
identity
.
Noun
.
String
(),
Codename
:
identity
.
Codename
,
Color
:
identity
.
Color
,
Extension
:
identity
.
Extension
,
CodesetVersion
:
identity
.
CodesetVersion
,
}
}
...
...
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