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
32d79d4e
Commit
32d79d4e
authored
2 years ago
by
Josh Brooks
Browse files
Options
Downloads
Patches
Plain Diff
Refactor bindings' notification implementation
parent
ed81d3ab
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!510
Release
,
!360
Implement Notifications for bindings
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/notifications.go
+27
-16
27 additions, 16 deletions
bindings/notifications.go
with
27 additions
and
16 deletions
bindings/notifications.go
+
27
−
16
View file @
32d79d4e
...
...
@@ -9,11 +9,12 @@ package bindings
import
(
"encoding/json"
"gitlab.com/elixxir/client/cmix/message"
"gitlab.com/elixxir/primitives/notifications"
)
// NotificationReports is a list of NotificationReport's. This will be returned
// via Notifications
ForMe
as a JSON marshalled byte data.
// via
Get
Notifications
Report
as a JSON marshalled byte data.
//
// Example JSON:
//
...
...
@@ -51,17 +52,19 @@ type NotificationReports []NotificationReport
// Below is a table that will define the contextual meaning of the Source field
// given all possible Type fields.
//
// TYPE SOURCE DESCRIPTION
// "default" recipient user ID A message with no association.
// "request" sender user ID A channel request has been received, from Source.
// "reset" sender user ID A channel reset has been received.
// "confirm" sender user ID A channel request has been accepted.
// "silent" sender user ID A message where the user should not be notified.
// "e2e" sender user ID A reception of an E2E message.
// "group" group ID A reception of a group chat message.
// "endFT" sender user ID The last message sent confirming end of file transfer.
// "groupRQ" sender user ID A request from Source to join a group chat.
// todo iterate over this docstring, ensure descriptions/sources are accurate
// TYPE | SOURCE | DESCRIPTION
// ________________________________________________________________________________________
// "default" | recipient user ID | A message with no association.
// "request" | sender user ID | A channel request has been received, from Source.
// "reset" | sender user ID | A channel reset has been received.
// "confirm" | sender user ID | A channel request has been accepted.
// "silent" | sender user ID | A message where the user should not be notified.
// "e2e" | sender user ID | A reception of an E2E message.
// "group" | group ID | A reception of a group chat message.
// "endFT" | sender user ID | The last message sent confirming end of file transfer.
// "groupRQ" | sender user ID | A request from Source to join a group chat.
// todo iterate over this docstring, ensure descriptions/sources are
// still accurate (they are from the old implementation
type
NotificationReport
struct
{
// ForMe determines whether this value is for the user. If it is
// false, this report may be ignored.
...
...
@@ -72,7 +75,7 @@ type NotificationReport struct {
Source
[]
byte
}
// Notifications
ForMe
parses the received notification data to determine which
//
Get
Notifications
Report
parses the received notification data to determine which
// notifications are for this user. // This returns the JSON-marshalled
// NotificationReports.
//
...
...
@@ -80,21 +83,29 @@ type NotificationReport struct {
// - 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.
//
// 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
NotificationsForMe
(
e2eId
int
,
notificationCSV
string
)
([]
byte
,
error
)
{
func
GetNotificationsReport
(
e2eId
int
,
notificationCSV
string
,
marshalledServices
[]
byte
)
([]
byte
,
error
)
{
// Retrieve user
user
,
err
:=
e2eTrackerSingleton
.
get
(
e2eId
)
if
err
!=
nil
{
return
nil
,
err
}
serviceList
:=
message
.
ServiceList
{}
err
=
json
.
Unmarshal
(
marshalledServices
,
&
serviceList
)
if
err
!=
nil
{
return
nil
,
err
}
// Retrieve the services for this user
serviceMap
:=
user
.
api
.
GetCmix
()
.
GetServices
()
services
:=
serviceMap
[
*
user
.
api
.
GetReceptionIdentity
()
.
ID
]
services
:=
serviceList
[
*
user
.
api
.
GetReceptionIdentity
()
.
ID
]
// Decode notifications' server data
notificationList
,
err
:=
notifications
.
DecodeNotificationsCSV
(
notificationCSV
)
...
...
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