mirror of
https://github.com/status-im/status-go.git
synced 2025-02-22 19:58:29 +00:00
Notifier constructor renamed
This commit is contained in:
parent
f159ea85a0
commit
9efed591da
@ -204,7 +204,7 @@ func (api *StatusAPI) Notify(token string) error {
|
||||
"sum": "Happy Day",
|
||||
}
|
||||
|
||||
err := api.b.notifier().Notify(msg, token)
|
||||
err := api.b.newNotification().Send(msg, token)
|
||||
if err != nil {
|
||||
log.Error("Notify failed:", err)
|
||||
}
|
||||
|
@ -24,12 +24,12 @@ const (
|
||||
// StatusBackend implements Status.im service
|
||||
type StatusBackend struct {
|
||||
sync.Mutex
|
||||
nodeReady chan struct{} // channel to wait for when node is fully ready
|
||||
nodeManager common.NodeManager
|
||||
accountManager common.AccountManager
|
||||
txQueueManager common.TxQueueManager
|
||||
jailManager common.JailManager
|
||||
notifier common.NotifierConstructor
|
||||
nodeReady chan struct{} // channel to wait for when node is fully ready
|
||||
nodeManager common.NodeManager
|
||||
accountManager common.AccountManager
|
||||
txQueueManager common.TxQueueManager
|
||||
jailManager common.JailManager
|
||||
newNotification common.NotificationConstructor
|
||||
}
|
||||
|
||||
// NewStatusBackend create a new NewStatusBackend instance
|
||||
@ -43,11 +43,11 @@ func NewStatusBackend() *StatusBackend {
|
||||
notificationManager := fcm.NewNotifier(fcmServerKey)
|
||||
|
||||
return &StatusBackend{
|
||||
nodeManager: nodeManager,
|
||||
accountManager: accountManager,
|
||||
jailManager: jailManager,
|
||||
txQueueManager: txQueueManager,
|
||||
notifier: notificationManager,
|
||||
nodeManager: nodeManager,
|
||||
accountManager: accountManager,
|
||||
jailManager: jailManager,
|
||||
txQueueManager: txQueueManager,
|
||||
newNotification: notificationManager,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,8 @@ package common
|
||||
|
||||
// Notifier manages Push Notifications.
|
||||
type Notifier interface {
|
||||
Notify(body interface{}, tokens ...string) error
|
||||
Send(body interface{}, tokens ...string) error
|
||||
}
|
||||
|
||||
// NotifierConstructor returns constructor of configured instance Notifier interface.
|
||||
type NotifierConstructor func() Notifier
|
||||
// NotificationConstructor returns constructor of configured instance Notifier interface.
|
||||
type NotificationConstructor func() Notifier
|
||||
|
@ -32,19 +32,19 @@ func (m *MockNotifier) EXPECT() *MockNotifierMockRecorder {
|
||||
return m.recorder
|
||||
}
|
||||
|
||||
// Notify mocks base method
|
||||
func (m *MockNotifier) Notify(body interface{}, tokens ...string) error {
|
||||
// Send mocks base method
|
||||
func (m *MockNotifier) Send(body interface{}, tokens ...string) error {
|
||||
varargs := []interface{}{body}
|
||||
for _, a := range tokens {
|
||||
varargs = append(varargs, a)
|
||||
}
|
||||
ret := m.ctrl.Call(m, "Notify", varargs...)
|
||||
ret := m.ctrl.Call(m, "Send", varargs...)
|
||||
ret0, _ := ret[0].(error)
|
||||
return ret0
|
||||
}
|
||||
|
||||
// Notify indicates an expected call of Notify
|
||||
func (mr *MockNotifierMockRecorder) Notify(body interface{}, tokens ...interface{}) *gomock.Call {
|
||||
// Send indicates an expected call of Send
|
||||
func (mr *MockNotifierMockRecorder) Send(body interface{}, tokens ...interface{}) *gomock.Call {
|
||||
varargs := append([]interface{}{body}, tokens...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Notify", reflect.TypeOf((*MockNotifier)(nil).Notify), varargs...)
|
||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockNotifier)(nil).Send), varargs...)
|
||||
}
|
||||
|
@ -12,14 +12,14 @@ type Notifier struct {
|
||||
}
|
||||
|
||||
// NewNotifier Firebase Cloud Messaging client constructor.
|
||||
func NewNotifier(key string) func() common.Notifier {
|
||||
func NewNotifier(key string) common.NotificationConstructor {
|
||||
return func() common.Notifier {
|
||||
return &Notifier{fcm.NewFcmClient(key)}
|
||||
}
|
||||
}
|
||||
|
||||
// Notify preparation and send to the tokens list.
|
||||
func (n *Notifier) Notify(body interface{}, tokens ...string) error {
|
||||
// Send send to the tokens list.
|
||||
func (n *Notifier) Send(body interface{}, tokens ...string) error {
|
||||
n.setPayload(¬ification.Payload{
|
||||
Title: "Status - new message",
|
||||
Body: "ping",
|
||||
|
@ -39,7 +39,7 @@ func (s *NotifierTestSuite) TestNotifySuccess() {
|
||||
s.fcmClientMock.EXPECT().Send().Return(nil, nil).Times(1)
|
||||
fcmClient := Notifier{s.fcmClientMock}
|
||||
|
||||
err := fcmClient.Notify(body, ids...)
|
||||
err := fcmClient.Send(body, ids...)
|
||||
|
||||
s.NoError(err)
|
||||
}
|
||||
@ -55,7 +55,7 @@ func (s *NotifierTestSuite) TestNotifyError() {
|
||||
s.fcmClientMock.EXPECT().Send().Return(nil, expectedError).Times(1)
|
||||
fcmClient := Notifier{s.fcmClientMock}
|
||||
|
||||
err := fcmClient.Notify(body, ids...)
|
||||
err := fcmClient.Send(body, ids...)
|
||||
|
||||
s.Equal(expectedError, err)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user