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
a842fef5
Commit
a842fef5
authored
2 years ago
by
Jono Wenger
Browse files
Options
Downloads
Plain Diff
Merge remote-tracking branch 'origin/release' into release
parents
977d6656
5ff6bbd6
No related branches found
No related tags found
1 merge request
!510
Release
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
bindings/notifications.go
+97
-0
97 additions, 0 deletions
bindings/notifications.go
with
97 additions
and
0 deletions
bindings/notifications.go
0 → 100644
+
97
−
0
View file @
a842fef5
////////////////////////////////////////////////////////////////////////////////
// Copyright © 2020 xx network SEZC //
// //
// Use of this source code is governed by a license that can be found in the //
// LICENSE file //
////////////////////////////////////////////////////////////////////////////////
package
bindings
// FIXME: This is the old NotificationsForMe code that needs to be fixed
/*
type NotificationForMeReport struct {
ForMe bool
Type string
Source []byte
}
type ManyNotificationForMeReport struct {
Many []*NotificationForMeReport
}
// NotificationsForMe Check if a notification received is for me
// It returns a NotificationForMeReport which contains a ForMe bool stating if it is for the caller,
// a Type, and a source. These are as follows:
// TYPE SOURCE DESCRIPTION
// "default" recipient user ID A message with no association
// "request" sender user ID A channel request has been received
// "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 which should not be notified on
// "e2e" sender user ID reception of an E2E message
// "group" group ID reception of a group chat message
// "endFT" sender user ID Last message sent confirming end of file transfer
// "groupRQ" sender user ID Request from sender to join a group chat
func NotificationsForMe(notifCSV, preimages string) (*ManyNotificationForMeReport, error) {
// Handle deserialization of preimages
var preimageList []edge.Preimage
if err := json.Unmarshal([]byte(preimages), &preimageList); err != nil {
return nil, errors.WithMessagef(err, "Failed to unmarshal the " +
"preimages list, cannot check if notification is for me")
}
list, err := notifications.DecodeNotificationsCSV(notifCSV)
if err != nil {
return nil, err
}
notifList := make([]*NotificationForMeReport, len(list))
for i, notifData := range list {
notifList[i] = &NotificationForMeReport{
ForMe: false,
Type: "",
Source: nil,
}
// check if any preimages match with the passed in data
for _, preimage := range preimageList {
if fingerprint.CheckIdentityFpFromMessageHash(notifData.IdentityFP, notifData.MessageHash, preimage.Data) {
notifList[i] = &NotificationForMeReport{
ForMe: true,
Type: preimage.Type,
Source: preimage.Source,
}
break
}
}
}
return &ManyNotificationForMeReport{notifList}, nil
}*/
// RegisterForNotifications allows a client to register for push notifications.
// The token is a firebase messaging token.
//
// Parameters:
// - e2eId - ID of the E2E object in the E2E tracker
func
RegisterForNotifications
(
e2eId
int
,
token
string
)
error
{
user
,
err
:=
e2eTrackerSingleton
.
get
(
e2eId
)
if
err
!=
nil
{
return
err
}
return
user
.
api
.
RegisterForNotifications
(
token
)
}
// UnregisterForNotifications turns off notifications for this client.
//
// Parameters:
// - e2eId - ID of the E2E object in the E2E tracker
func
UnregisterForNotifications
(
e2eId
int
)
error
{
user
,
err
:=
e2eTrackerSingleton
.
get
(
e2eId
)
if
err
!=
nil
{
return
err
}
return
user
.
api
.
UnregisterForNotifications
()
}
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