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"
|
||||
)
|
||||
|
||||
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),
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Reference in New Issue