Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
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
client
Commits
492b1a40
Commit
492b1a40
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Add group chat MessageReceive documentation
parent
6011849a
No related branches found
No related tags found
2 merge requests
!510
Release
,
!375
Add group chat MessageReceive documentation
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/group.go
+42
-1
42 additions, 1 deletion
bindings/group.go
with
42 additions
and
1 deletion
bindings/group.go
+
42
−
1
View file @
492b1a40
...
...
@@ -410,6 +410,7 @@ type GroupRequest interface {
}
// GroupChatProcessor manages the handling of received group chat messages.
// The decryptedMessage field will be a JSON marshalled GroupChatMessage.
type
GroupChatProcessor
interface
{
Process
(
decryptedMessage
,
msg
,
receptionId
[]
byte
,
ephemeralId
,
roundId
int64
,
err
error
)
...
...
@@ -422,13 +423,53 @@ type groupChatProcessor struct {
bindingsCb
GroupChatProcessor
}
// GroupChatMessage is the bindings layer representation of the
// [groupChat.MessageReceive].
//
// GroupChatMessage Example JSON:
// {
// "GroupId": "AAAAAAAJlasAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAE",
// "SenderId": "AAAAAAAAB8gAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD",
// "MessageId": "Zm9ydHkgZml2ZQAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=",
// "Payload": "Zm9ydHkgZml2ZQ==",
// "Timestamp": 1663009269474079000
// }
type
GroupChatMessage
struct
{
// GroupId is the ID of the group that this message was sent on.
GroupId
[]
byte
// SenderId is the ID of the sender of this message.
SenderId
[]
byte
// MessageId is the ID of this group message.
MessageId
[]
byte
// Payload is the content of the message.
Payload
[]
byte
// Timestamp is the time this message was sent on.
Timestamp
int64
}
// convertMessageReceive is a helper function which converts a
// [groupChat.MessageReceive] to the bindings-layer representation GroupChatMessage.
func
convertMessageReceive
(
decryptedMsg
gc
.
MessageReceive
)
GroupChatMessage
{
return
GroupChatMessage
{
GroupId
:
decryptedMsg
.
GroupID
.
Bytes
(),
SenderId
:
decryptedMsg
.
SenderID
.
Bytes
(),
MessageId
:
decryptedMsg
.
ID
.
Bytes
(),
Payload
:
decryptedMsg
.
Payload
,
Timestamp
:
decryptedMsg
.
Timestamp
.
UnixNano
(),
}
}
// convertProcessor turns the input of a groupChat.Processor to the
// binding-layer primitives equivalents within the GroupChatProcessor.Process.
func
convertGroupChatProcessor
(
decryptedMsg
gc
.
MessageReceive
,
msg
format
.
Message
,
receptionID
receptionID
.
EphemeralIdentity
,
round
rounds
.
Round
)
(
decryptedMessage
,
message
,
receptionId
[]
byte
,
ephemeralId
,
roundId
int64
,
err
error
)
{
decryptedMessage
,
err
=
json
.
Marshal
(
decryptedMsg
)
decryptedMessage
,
err
=
json
.
Marshal
(
convertMessageReceive
(
decryptedMsg
)
)
message
=
msg
.
Marshal
()
receptionId
=
receptionID
.
Source
.
Marshal
()
ephemeralId
=
receptionID
.
EphId
.
Int64
()
...
...
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