Show correct text in case of mentions

This commit is contained in:
Andrea Maria Piana 2020-09-03 08:58:58 +02:00
parent 18877cae6f
commit 0d998e1858
No known key found for this signature in database
GPG Key ID: AA6CCA6DE0E06424
2 changed files with 15 additions and 5 deletions

View File

@ -12,7 +12,8 @@ import (
"github.com/status-im/status-go/protocol/protobuf"
)
const defaultNotificationMessage = "You have a new message"
const defaultNewMessageNotificationText = "You have a new message"
const defaultMentionNotificationText = "Someone mentioned you"
type GoRushRequestData struct {
EncryptedMessage string `json:"encryptedMessage"`
@ -52,11 +53,17 @@ func PushNotificationRegistrationToGoRushRequest(requestAndRegistrations []*Requ
for _, requestAndRegistration := range requestAndRegistrations {
request := requestAndRegistration.Request
registration := requestAndRegistration.Registration
var text string
if request.Type == protobuf.PushNotification_MESSAGE {
text = defaultNewMessageNotificationText
} else {
text = defaultMentionNotificationText
}
goRushRequests.Notifications = append(goRushRequests.Notifications,
&GoRushRequestNotification{
Tokens: []string{registration.DeviceToken},
Platform: tokenTypeToGoRushPlatform(registration.TokenType),
Message: defaultNotificationMessage,
Message: text,
Topic: registration.ApnTopic,
Data: &GoRushRequestData{
EncryptedMessage: types.EncodeHex(request.Message),

View File

@ -33,6 +33,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Request: &protobuf.PushNotification{
ChatId: chatID,
Type: protobuf.PushNotification_MESSAGE,
PublicKey: publicKey1,
InstallationId: installationID1,
Message: message1,
@ -45,6 +46,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Request: &protobuf.PushNotification{
ChatId: chatID,
Type: protobuf.PushNotification_MESSAGE,
PublicKey: publicKey1,
InstallationId: installationID2,
Message: message2,
@ -57,6 +59,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Request: &protobuf.PushNotification{
ChatId: chatID,
Type: protobuf.PushNotification_MENTION,
PublicKey: publicKey2,
InstallationId: installationID3,
Message: message3,
@ -73,7 +76,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Tokens: []string{token1},
Platform: platform1,
Message: defaultNotificationMessage,
Message: defaultNewMessageNotificationText,
Data: &GoRushRequestData{
EncryptedMessage: hexMessage1,
ChatID: types.EncodeHex(chatID),
@ -83,7 +86,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Tokens: []string{token2},
Platform: platform2,
Message: defaultNotificationMessage,
Message: defaultNewMessageNotificationText,
Data: &GoRushRequestData{
EncryptedMessage: hexMessage2,
ChatID: types.EncodeHex(chatID),
@ -93,7 +96,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
{
Tokens: []string{token3},
Platform: platform3,
Message: defaultNotificationMessage,
Message: defaultMentionNotificationText,
Data: &GoRushRequestData{
EncryptedMessage: hexMessage3,
ChatID: types.EncodeHex(chatID),