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
ce711549
Commit
ce711549
authored
2 years ago
by
Jake Taylor
Browse files
Options
Downloads
Plain Diff
Merge branch 'XX-4188/NotificationsBindings' into 'release'
Add documentation See merge request
!442
parents
3135a3e1
e42c8421
Branches
Branches containing commit
Tags
Tags containing commit
2 merge requests
!510
Release
,
!442
Add documentation
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
bindings/follow.go
+107
-75
107 additions, 75 deletions
bindings/follow.go
bindings/notifications.go
+69
-71
69 additions, 71 deletions
bindings/notifications.go
with
176 additions
and
146 deletions
bindings/follow.go
+
107
−
75
View file @
ce711549
...
...
@@ -106,6 +106,7 @@ func (c *Cmix) ReadyToSend() bool {
// is to being ready.
//
// Example JSON:
//
// {
// "IsReady": true,
// "HowClose": 0.534
...
...
@@ -117,6 +118,7 @@ type IsReadyInfo struct {
// NetworkFollowerStatus gets the state of the network follower. It returns a
// status with the following values:
//
// Stopped - 0
// Running - 2000
// Stopping - 3000
...
...
@@ -215,6 +217,7 @@ func (c *Cmix) IsHealthy() bool {
// - []byte - A JSON marshalled list of all running processes.
//
// JSON Example:
//
// {
// "FileTransfer{BatchBuilderThread, FilePartSendingThread#0, FilePartSendingThread#1, FilePartSendingThread#2, FilePartSendingThread#3}",
// "MessageReception Worker 0"
...
...
@@ -267,6 +270,7 @@ func (c *Cmix) RegisterClientErrorCallback(clientError ClientError) {
// - err - JSON unmarshalling error
//
// Example JSON:
//
// [
// {
// "Id": "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD", // bytes of id.ID encoded as base64 string
...
...
@@ -293,10 +297,38 @@ type TrackServicesCallback interface {
Callback
(
marshalData
[]
byte
,
err
error
)
}
// TrackServicesWithIdentity will return via a callback the list of services the
// backend keeps track of for the provided identity. This may be passed into
// other bindings call which may need context on the available services for this
// single identity. This will only return services for the given identity.
//
// Parameters:
// - e2eID - e2e object ID in the tracker.
// - cb - A TrackServicesCallback, which will be passed the marshalled
// message.ServiceList.
func
(
c
*
Cmix
)
TrackServicesWithIdentity
(
e2eId
int
,
cb
TrackServicesCallback
)
error
{
// Retrieve the user from the tracker
user
,
err
:=
e2eTrackerSingleton
.
get
(
e2eId
)
if
err
!=
nil
{
return
err
}
receptionId
:=
user
.
api
.
GetReceptionIdentity
()
.
ID
c
.
api
.
GetCmix
()
.
TrackServices
(
func
(
list
message
.
ServiceList
)
{
res
:=
make
(
message
.
ServiceList
)
res
[
*
receptionId
]
=
list
[
*
receptionId
]
cb
.
Callback
(
json
.
Marshal
(
res
))
})
return
nil
}
// TrackServices will return via a callback the list of services the
// backend keeps track of, which is formally referred to as a
// [message.ServiceList]. This may be passed into other bindings call which
// may need context on the available services for this client.
// may need context on the available services for this client. This will
// provide services for all identities that the client tracks.
//
// Parameters:
// - cb - A TrackServicesCallback, which will be passed the marshalled
...
...
This diff is collapsed.
Click to expand it.
bindings/notifications.go
+
69
−
71
View file @
ce711549
...
...
@@ -17,6 +17,7 @@ import (
// via GetNotificationsReport as a JSON marshalled byte data.
//
// Example JSON:
//
// [
// {
// "ForMe": true, // boolean
...
...
@@ -44,6 +45,7 @@ type NotificationReports []NotificationReport
// this user.
//
// Example NotificationReport JSON:
//
// {
// "ForMe": true,
// "Type": "e2e",
...
...
@@ -80,33 +82,27 @@ type NotificationReport struct {
// NotificationReports.
//
// Parameters:
// - e2eID - e2e object ID in the tracker
// - notificationCSV - the notification data received from the
// notifications' server.
// - marshalledServices - the JSON-marshalled list of services the backend
// keeps track of. Refer to Cmix.TrackServices for information about this.
// keeps track of. Refer to Cmix.TrackServices or
// Cmix.TrackServicesWithIdentity for information about this.
//
// Returns:
// - []byte - A JSON marshalled NotificationReports. Some NotificationReport's
// within in this structure may have their NotificationReport.ForMe
// set to false. These may be ignored.
func
GetNotificationsReport
(
e2eId
int
,
notificationCSV
string
,
func
GetNotificationsReport
(
notificationCSV
string
,
marshalledServices
[]
byte
)
([]
byte
,
error
)
{
// Retrieve user
user
,
err
:=
e2eTrackerSingleton
.
get
(
e2eId
)
if
err
!=
nil
{
return
nil
,
err
}
// If services are retrieved using TrackServicesWithIdentity, this
// should return a single list.
serviceList
:=
message
.
ServiceList
{}
err
=
json
.
Unmarshal
(
marshalledServices
,
&
serviceList
)
err
:
=
json
.
Unmarshal
(
marshalledServices
,
&
serviceList
)
if
err
!=
nil
{
return
nil
,
err
}
// Retrieve the services for this user
services
:=
serviceList
[
*
user
.
api
.
GetReceptionIdentity
()
.
ID
]
// Decode notifications' server data
notificationList
,
err
:=
notifications
.
DecodeNotificationsCSV
(
notificationCSV
)
if
err
!=
nil
{
...
...
@@ -117,6 +113,7 @@ func GetNotificationsReport(e2eId int, notificationCSV string,
reportList
:=
make
([]
*
NotificationReport
,
len
(
notificationList
))
// Iterate over data provided by server
for
_
,
services
:=
range
serviceList
{
for
i
:=
range
notificationList
{
notifData
:=
notificationList
[
i
]
...
...
@@ -139,6 +136,7 @@ func GetNotificationsReport(e2eId int, notificationCSV string,
}
}
}
}
return
json
.
Marshal
(
reportList
)
}
...
...
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