Skip to content
Snippets Groups Projects
Commit b90d51a3 authored by Josh Brooks's avatar Josh Brooks
Browse files

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!5Release
......@@ -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{
"MessageHash": base64.StdEncoding.EncodeToString(data.MessageHash),
"IdentityFingerprint": base64.StdEncoding.EncodeToString(data.IdentityFP),
"messagehash": base64.StdEncoding.EncodeToString(data.MessageHash),
"identityfingerprint": 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{}{
"MessageHash": base64.StdEncoding.EncodeToString(data.MessageHash),
"IdentityFingerprint": base64.StdEncoding.EncodeToString(data.IdentityFP),
"messagehash": base64.StdEncoding.EncodeToString(data.MessageHash),
"identityfingerprint": base64.StdEncoding.EncodeToString(data.IdentityFP),
},
},
},
......
......@@ -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
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment