Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
notifications-bot
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
archives
notifications-bot
Commits
b90d51a3
Commit
b90d51a3
authored
May 17, 2021
by
Josh Brooks
Browse files
Options
Downloads
Plain Diff
Merge branch 'release' of gitlab.com:elixxir/notifications-bot into et/RegTimestamp
parents
ee0c2a80
e16878c4
No related branches found
No related tags found
1 merge request
!5
Release
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
firebase/fcm.go
+9
-10
9 additions, 10 deletions
firebase/fcm.go
notifications/notifications.go
+2
-2
2 additions, 2 deletions
notifications/notifications.go
with
11 additions
and
12 deletions
firebase/fcm.go
+
9
−
10
View file @
b90d51a3
...
...
@@ -11,6 +11,7 @@ import (
"github.com/pkg/errors"
"gitlab.com/elixxir/comms/mixmessages"
"testing"
"time"
"golang.org/x/net/context"
...
...
@@ -74,26 +75,24 @@ func SetupMessagingApp(serviceKeyPath string) (*messaging.Client, error) {
// returns string, error (string is of dubious use, but is returned for the time being)
func
sendNotification
(
app
FBSender
,
token
string
,
data
*
mixmessages
.
NotificationData
)
(
string
,
error
)
{
ctx
:=
context
.
Background
()
ttl
:=
6
*
time
.
Hour
message
:=
&
messaging
.
Message
{
Notification
:
nil
,
// This must remain nil for the data to go to android apps in background
Android
:
&
messaging
.
AndroidConfig
{
Priority
:
"high"
,
}
,
TTL
:
&
ttl
,
Data
:
map
[
string
]
string
{
"M
essage
H
ash"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
MessageHash
),
"I
dentity
F
ingerprint"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
IdentityFP
),
"m
essage
h
ash"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
MessageHash
),
"i
dentity
f
ingerprint"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
IdentityFP
),
},
APNS
:
&
messaging
.
APNSConfig
{
// APNS is apple's native notification service, this is ios specific config
Headers
:
map
[
string
]
string
{
"apns-priority"
:
"5"
,
},
APNS
:
&
messaging
.
APNSConfig
{
// APNS is apple's native notification service, this is ios specific config
Payload
:
&
messaging
.
APNSPayload
{
Aps
:
&
messaging
.
Aps
{
ContentAvailable
:
true
,
},
CustomData
:
map
[
string
]
interface
{}{
"
M
essage
H
ash"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
MessageHash
),
"
I
dentity
F
ingerprint"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
IdentityFP
),
"
m
essage
h
ash"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
MessageHash
),
"
i
dentity
f
ingerprint"
:
base64
.
StdEncoding
.
EncodeToString
(
data
.
IdentityFP
),
},
},
},
...
...
This diff is collapsed.
Click to expand it.
notifications/notifications.go
+
2
−
2
View file @
b90d51a3
...
...
@@ -139,7 +139,7 @@ func notifyUser(data *pb.NotificationData, fcm *messaging.Client, fc *firebase.F
return
errors
.
WithMessagef
(
err
,
"Failed to lookup user with tRSA hash %+v"
,
e
.
TransmissionRSAHash
)
}
_
,
err
=
fc
.
SendNotification
(
fcm
,
u
.
Token
,
data
)
resp
,
err
:
=
fc
.
SendNotification
(
fcm
,
u
.
Token
,
data
)
if
err
!=
nil
{
// Catch two firebase errors that we don't want to crash on
// 403 and 404 indicate that the token stored is incorrect
...
...
@@ -156,7 +156,7 @@ func notifyUser(data *pb.NotificationData, fcm *messaging.Client, fc *firebase.F
return
errors
.
WithMessagef
(
err
,
"Failed to send notification to user with tRSA hash %+v"
,
u
.
TransmissionRSAHash
)
}
}
jww
.
INFO
.
Printf
(
"Notified ephemeral ID %+v"
,
data
.
EphemeralID
)
jww
.
INFO
.
Printf
(
"Notified ephemeral ID
%+v [%+v] and received response
%+v"
,
data
.
EphemeralID
,
u
.
Token
,
resp
)
return
nil
}
...
...
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