All notifiers remaned into notification
This commit is contained in:
parent
d22cdc5cbb
commit
c823acfd04
|
@ -40,7 +40,7 @@ func NewStatusBackend() *StatusBackend {
|
|||
accountManager := account.NewManager(nodeManager)
|
||||
txQueueManager := txqueue.NewManager(nodeManager, accountManager)
|
||||
jailManager := jail.New(nodeManager)
|
||||
notificationManager := fcm.NewNotifier(fcmServerKey)
|
||||
notificationManager := fcm.NewNotification(fcmServerKey)
|
||||
|
||||
return &StatusBackend{
|
||||
nodeManager: nodeManager,
|
||||
|
|
|
@ -6,20 +6,20 @@ import (
|
|||
"github.com/status-im/status-go/geth/notification"
|
||||
)
|
||||
|
||||
// Notifier represents messaging provider for notifications.
|
||||
type Notifier struct {
|
||||
// Notification represents messaging provider for notifications.
|
||||
type Notification struct {
|
||||
client firebaseClient
|
||||
}
|
||||
|
||||
// NewNotifier Firebase Cloud Messaging client constructor.
|
||||
func NewNotifier(key string) common.NotificationConstructor {
|
||||
// NewNotification Firebase Cloud Messaging client constructor.
|
||||
func NewNotification(key string) common.NotificationConstructor {
|
||||
return func() common.Notifier {
|
||||
return &Notifier{fcm.NewFcmClient(key)}
|
||||
return &Notification{fcm.NewFcmClient(key)}
|
||||
}
|
||||
}
|
||||
|
||||
// Send send to the tokens list.
|
||||
func (n *Notifier) Send(body interface{}, tokens ...string) error {
|
||||
func (n *Notification) Send(body interface{}, tokens ...string) error {
|
||||
n.setPayload(¬ification.Payload{
|
||||
Title: "Status - new message",
|
||||
Body: "ping",
|
||||
|
@ -32,17 +32,17 @@ func (n *Notifier) Send(body interface{}, tokens ...string) error {
|
|||
}
|
||||
|
||||
// SetMessage to send for given the tokens list.
|
||||
func (n *Notifier) setMessage(body interface{}, tokens ...string) {
|
||||
func (n *Notification) setMessage(body interface{}, tokens ...string) {
|
||||
n.client.NewFcmRegIdsMsg(tokens, body)
|
||||
}
|
||||
|
||||
// SetPayload sets payload message information.
|
||||
func (n *Notifier) setPayload(payload *notification.Payload) {
|
||||
func (n *Notification) setPayload(payload *notification.Payload) {
|
||||
fcmPayload := n.toFCMPayload(payload)
|
||||
n.client.SetNotificationPayload(fcmPayload)
|
||||
}
|
||||
|
||||
func (n *Notifier) toFCMPayload(payload *notification.Payload) *fcm.NotificationPayload {
|
||||
func (n *Notification) toFCMPayload(payload *notification.Payload) *fcm.NotificationPayload {
|
||||
return &fcm.NotificationPayload{
|
||||
Title: payload.Title,
|
||||
Body: payload.Body,
|
|
@ -37,7 +37,7 @@ func (s *NotifierTestSuite) TestNotifySuccess() {
|
|||
s.fcmClientMock.EXPECT().SetNotificationPayload(fcmPayload).Times(1)
|
||||
s.fcmClientMock.EXPECT().NewFcmRegIdsMsg(ids, body).Times(1)
|
||||
s.fcmClientMock.EXPECT().Send().Return(nil, nil).Times(1)
|
||||
fcmClient := Notifier{s.fcmClientMock}
|
||||
fcmClient := Notification{s.fcmClientMock}
|
||||
|
||||
err := fcmClient.Send(body, ids...)
|
||||
|
||||
|
@ -53,7 +53,7 @@ func (s *NotifierTestSuite) TestNotifyError() {
|
|||
s.fcmClientMock.EXPECT().SetNotificationPayload(fcmPayload).Times(1)
|
||||
s.fcmClientMock.EXPECT().NewFcmRegIdsMsg(ids, body).Times(1)
|
||||
s.fcmClientMock.EXPECT().Send().Return(nil, expectedError).Times(1)
|
||||
fcmClient := Notifier{s.fcmClientMock}
|
||||
fcmClient := Notification{s.fcmClientMock}
|
||||
|
||||
err := fcmClient.Send(body, ids...)
|
||||
|
Loading…
Reference in New Issue