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
60acb356
Commit
60acb356
authored
2 years ago
by
Benjamin Wenger
Browse files
Options
Downloads
Patches
Plain Diff
fixed capitilization of variables and the stringer for message types
parent
0c7763ba
Branches
Branches containing commit
Tags
Tags containing commit
5 merge requests
!510
Release
,
!419
rewrote the health tracker to both consider if there are waiting rounds and...
,
!371
[Channel RSAtoPrivate] Implement Reverse Asymmetric in Client/Broadcast
,
!354
Channels impl
,
!340
Project/channels
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
channels/eventModel.go
+27
-27
27 additions, 27 deletions
channels/eventModel.go
channels/messageTypes.go
+4
-0
4 additions, 0 deletions
channels/messageTypes.go
with
31 additions
and
27 deletions
channels/eventModel.go
+
27
−
27
View file @
60acb356
...
...
@@ -29,13 +29,13 @@ type EventModel interface {
JoinChannel
(
channel
cryptoBroadcast
.
Channel
)
// LeaveChannel is called whenever a channel is left locally
LeaveChannel
(
C
hannelID
*
id
.
ID
)
LeaveChannel
(
c
hannelID
*
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
ReceiveMessage
(
C
hannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
S
enderUsername
string
,
text
string
,
ReceiveMessage
(
c
hannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
s
enderUsername
string
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
// ReceiveReply is called whenever a message is received which is a reply
...
...
@@ -43,8 +43,8 @@ type EventModel interface {
// it is incumbent on the user of the API to filter such called by message 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.
ReceiveReply
(
ChannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
R
eplyTo
cryptoChannel
.
MessageID
,
SenderUsername
string
,
ReceiveReply
(
ChannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
r
eplyTo
cryptoChannel
.
MessageID
,
SenderUsername
string
,
text
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
...
...
@@ -53,9 +53,9 @@ type EventModel interface {
// it is incumbent on the user of the API to filter such called by message 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.
ReceiveReaction
(
C
hannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
R
eactionTo
cryptoChannel
.
MessageID
,
S
enderUsername
string
,
R
eaction
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
ReceiveReaction
(
c
hannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
r
eactionTo
cryptoChannel
.
MessageID
,
s
enderUsername
string
,
r
eaction
string
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
//unimplemented
...
...
@@ -65,9 +65,9 @@ type EventModel interface {
//UnPinMessage(ChannelID *id.ID, MessageID cryptoChannel.MessageID)
}
type
MessageTypeReceiveMessage
func
(
C
hannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
S
enderUsername
string
,
C
ontent
[]
byte
,
timestamp
time
.
Time
,
type
MessageTypeReceiveMessage
func
(
c
hannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
s
enderUsername
string
,
c
ontent
[]
byte
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
type
events
struct
{
...
...
@@ -168,15 +168,15 @@ func (e *events) triggerAdminEvent(chID *id.ID, cm *ChannelMessage,
// function on the event model.
// If the message has a reply but it is malformed, it will drop the reply and
// write to the log
func
(
e
*
events
)
receiveTextMessage
(
C
hannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
S
enderUsername
string
,
C
ontent
[]
byte
,
timestamp
time
.
Time
,
func
(
e
*
events
)
receiveTextMessage
(
c
hannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
s
enderUsername
string
,
c
ontent
[]
byte
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
{
txt
:=
&
CMIXChannelText
{}
if
err
:=
proto
.
Unmarshal
(
C
ontent
,
txt
);
err
!=
nil
{
if
err
:=
proto
.
Unmarshal
(
c
ontent
,
txt
);
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to text unmarshal message %s from %s on "
+
"channel %s, type %s, ts: %s, lease: %s, round: %d: %+v"
,
M
essageID
,
S
enderUsername
,
C
hannelID
,
messageType
,
timestamp
,
lease
,
m
essageID
,
s
enderUsername
,
c
hannelID
,
messageType
,
timestamp
,
lease
,
round
.
ID
,
err
)
return
}
...
...
@@ -185,7 +185,7 @@ func (e *events) receiveTextMessage(ChannelID *id.ID,
if
len
(
txt
.
ReplyMessageID
)
==
cryptoChannel
.
MessageIDLen
{
var
replyTo
cryptoChannel
.
MessageID
copy
(
replyTo
[
:
],
txt
.
ReplyMessageID
)
e
.
model
.
ReceiveReply
(
C
hannelID
,
M
essageID
,
replyTo
,
S
enderUsername
,
txt
.
Text
,
e
.
model
.
ReceiveReply
(
c
hannelID
,
m
essageID
,
replyTo
,
s
enderUsername
,
txt
.
Text
,
timestamp
,
lease
,
round
)
return
...
...
@@ -193,12 +193,12 @@ func (e *events) receiveTextMessage(ChannelID *id.ID,
jww
.
ERROR
.
Printf
(
"Failed process reply to for message %s from %s on "
+
"channel %s, type %s, ts: %s, lease: %s, round: %d, returning "
+
"without reply"
,
M
essageID
,
S
enderUsername
,
C
hannelID
,
messageType
,
timestamp
,
lease
,
m
essageID
,
s
enderUsername
,
c
hannelID
,
messageType
,
timestamp
,
lease
,
round
.
ID
)
}
}
e
.
model
.
ReceiveMessage
(
C
hannelID
,
M
essageID
,
S
enderUsername
,
txt
.
Text
,
e
.
model
.
ReceiveMessage
(
c
hannelID
,
m
essageID
,
s
enderUsername
,
txt
.
Text
,
timestamp
,
lease
,
round
)
}
...
...
@@ -208,15 +208,15 @@ func (e *events) receiveTextMessage(ChannelID *id.ID,
// If the received reaction is not, the reaction is dropped.
// If the messageID for the message the reaction is to is malformed, the reaction
// is dropped.
func
(
e
*
events
)
receiveReaction
(
C
hannelID
*
id
.
ID
,
M
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
S
enderUsername
string
,
C
ontent
[]
byte
,
timestamp
time
.
Time
,
func
(
e
*
events
)
receiveReaction
(
c
hannelID
*
id
.
ID
,
m
essageID
cryptoChannel
.
MessageID
,
messageType
MessageType
,
s
enderUsername
string
,
c
ontent
[]
byte
,
timestamp
time
.
Time
,
lease
time
.
Duration
,
round
rounds
.
Round
)
{
react
:=
&
CMIXChannelReaction
{}
if
err
:=
proto
.
Unmarshal
(
C
ontent
,
react
);
err
!=
nil
{
if
err
:=
proto
.
Unmarshal
(
c
ontent
,
react
);
err
!=
nil
{
jww
.
ERROR
.
Printf
(
"Failed to text unmarshal message %s from %s on "
+
"channel %s, type %s, ts: %s, lease: %s, round: %d: %+v"
,
M
essageID
,
S
enderUsername
,
C
hannelID
,
messageType
,
timestamp
,
lease
,
m
essageID
,
s
enderUsername
,
c
hannelID
,
messageType
,
timestamp
,
lease
,
round
.
ID
,
err
)
return
}
...
...
@@ -226,20 +226,20 @@ func (e *events) receiveReaction(ChannelID *id.ID,
jww
.
ERROR
.
Printf
(
"Failed process reaction %s from %s on channel "
+
"%s, type %s, ts: %s, lease: %s, round: %d, due to malformed "
+
"reaction (%s), ignoring reaction"
,
M
essageID
,
S
enderUsername
,
C
hannelID
,
messageType
,
timestamp
,
lease
,
m
essageID
,
s
enderUsername
,
c
hannelID
,
messageType
,
timestamp
,
lease
,
round
.
ID
,
err
)
}
if
react
.
ReactionMessageID
!=
nil
&&
len
(
react
.
ReactionMessageID
)
==
cryptoChannel
.
MessageIDLen
{
var
reactTo
cryptoChannel
.
MessageID
copy
(
reactTo
[
:
],
react
.
ReactionMessageID
)
e
.
model
.
ReceiveReaction
(
C
hannelID
,
M
essageID
,
reactTo
,
S
enderUsername
,
e
.
model
.
ReceiveReaction
(
c
hannelID
,
m
essageID
,
reactTo
,
s
enderUsername
,
react
.
Reaction
,
timestamp
,
lease
,
round
)
}
else
{
jww
.
ERROR
.
Printf
(
"Failed process reaction %s from %s on channel "
+
"%s, type %s, ts: %s, lease: %s, round: %d, reacting to "
+
"invalid message, ignoring reaction"
,
M
essageID
,
S
enderUsername
,
C
hannelID
,
messageType
,
timestamp
,
lease
,
m
essageID
,
s
enderUsername
,
c
hannelID
,
messageType
,
timestamp
,
lease
,
round
.
ID
)
}
}
This diff is collapsed.
Click to expand it.
channels/messageTypes.go
+
4
−
0
View file @
60acb356
...
...
@@ -14,6 +14,10 @@ func (mt MessageType) String() string {
switch
mt
{
case
Text
:
return
"Text"
case
AdminText
:
return
"AdminText"
case
Reaction
:
return
"Reaction"
default
:
return
fmt
.
Sprintf
(
"Unknown messageType %d"
,
mt
)
}
...
...
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