Show correct text in case of mentions
This commit is contained in:
parent
18877cae6f
commit
0d998e1858
|
@ -12,7 +12,8 @@ import (
|
||||||
"github.com/status-im/status-go/protocol/protobuf"
|
"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 {
|
type GoRushRequestData struct {
|
||||||
EncryptedMessage string `json:"encryptedMessage"`
|
EncryptedMessage string `json:"encryptedMessage"`
|
||||||
|
@ -52,11 +53,17 @@ func PushNotificationRegistrationToGoRushRequest(requestAndRegistrations []*Requ
|
||||||
for _, requestAndRegistration := range requestAndRegistrations {
|
for _, requestAndRegistration := range requestAndRegistrations {
|
||||||
request := requestAndRegistration.Request
|
request := requestAndRegistration.Request
|
||||||
registration := requestAndRegistration.Registration
|
registration := requestAndRegistration.Registration
|
||||||
|
var text string
|
||||||
|
if request.Type == protobuf.PushNotification_MESSAGE {
|
||||||
|
text = defaultNewMessageNotificationText
|
||||||
|
} else {
|
||||||
|
text = defaultMentionNotificationText
|
||||||
|
}
|
||||||
goRushRequests.Notifications = append(goRushRequests.Notifications,
|
goRushRequests.Notifications = append(goRushRequests.Notifications,
|
||||||
&GoRushRequestNotification{
|
&GoRushRequestNotification{
|
||||||
Tokens: []string{registration.DeviceToken},
|
Tokens: []string{registration.DeviceToken},
|
||||||
Platform: tokenTypeToGoRushPlatform(registration.TokenType),
|
Platform: tokenTypeToGoRushPlatform(registration.TokenType),
|
||||||
Message: defaultNotificationMessage,
|
Message: text,
|
||||||
Topic: registration.ApnTopic,
|
Topic: registration.ApnTopic,
|
||||||
Data: &GoRushRequestData{
|
Data: &GoRushRequestData{
|
||||||
EncryptedMessage: types.EncodeHex(request.Message),
|
EncryptedMessage: types.EncodeHex(request.Message),
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Request: &protobuf.PushNotification{
|
Request: &protobuf.PushNotification{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
Type: protobuf.PushNotification_MESSAGE,
|
||||||
PublicKey: publicKey1,
|
PublicKey: publicKey1,
|
||||||
InstallationId: installationID1,
|
InstallationId: installationID1,
|
||||||
Message: message1,
|
Message: message1,
|
||||||
|
@ -45,6 +46,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Request: &protobuf.PushNotification{
|
Request: &protobuf.PushNotification{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
Type: protobuf.PushNotification_MESSAGE,
|
||||||
PublicKey: publicKey1,
|
PublicKey: publicKey1,
|
||||||
InstallationId: installationID2,
|
InstallationId: installationID2,
|
||||||
Message: message2,
|
Message: message2,
|
||||||
|
@ -57,6 +59,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Request: &protobuf.PushNotification{
|
Request: &protobuf.PushNotification{
|
||||||
ChatId: chatID,
|
ChatId: chatID,
|
||||||
|
Type: protobuf.PushNotification_MENTION,
|
||||||
PublicKey: publicKey2,
|
PublicKey: publicKey2,
|
||||||
InstallationId: installationID3,
|
InstallationId: installationID3,
|
||||||
Message: message3,
|
Message: message3,
|
||||||
|
@ -73,7 +76,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Tokens: []string{token1},
|
Tokens: []string{token1},
|
||||||
Platform: platform1,
|
Platform: platform1,
|
||||||
Message: defaultNotificationMessage,
|
Message: defaultNewMessageNotificationText,
|
||||||
Data: &GoRushRequestData{
|
Data: &GoRushRequestData{
|
||||||
EncryptedMessage: hexMessage1,
|
EncryptedMessage: hexMessage1,
|
||||||
ChatID: types.EncodeHex(chatID),
|
ChatID: types.EncodeHex(chatID),
|
||||||
|
@ -83,7 +86,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Tokens: []string{token2},
|
Tokens: []string{token2},
|
||||||
Platform: platform2,
|
Platform: platform2,
|
||||||
Message: defaultNotificationMessage,
|
Message: defaultNewMessageNotificationText,
|
||||||
Data: &GoRushRequestData{
|
Data: &GoRushRequestData{
|
||||||
EncryptedMessage: hexMessage2,
|
EncryptedMessage: hexMessage2,
|
||||||
ChatID: types.EncodeHex(chatID),
|
ChatID: types.EncodeHex(chatID),
|
||||||
|
@ -93,7 +96,7 @@ func TestPushNotificationRegistrationToGoRushRequest(t *testing.T) {
|
||||||
{
|
{
|
||||||
Tokens: []string{token3},
|
Tokens: []string{token3},
|
||||||
Platform: platform3,
|
Platform: platform3,
|
||||||
Message: defaultNotificationMessage,
|
Message: defaultMentionNotificationText,
|
||||||
Data: &GoRushRequestData{
|
Data: &GoRushRequestData{
|
||||||
EncryptedMessage: hexMessage3,
|
EncryptedMessage: hexMessage3,
|
||||||
ChatID: types.EncodeHex(chatID),
|
ChatID: types.EncodeHex(chatID),
|
||||||
|
|
Loading…
Reference in New Issue