[#755] Restructure notifier interfaces
This commit is contained in:
parent
8b94ac00bb
commit
e22fa36111
1
Makefile
1
Makefile
|
@ -113,7 +113,6 @@ mock-install: ##@other Install mocking tools
|
||||||
mock: ##@other Regenerate mocks
|
mock: ##@other Regenerate mocks
|
||||||
mockgen -source=geth/common/types.go -destination=geth/common/types_mock.go -package=common
|
mockgen -source=geth/common/types.go -destination=geth/common/types_mock.go -package=common
|
||||||
mockgen -source=geth/mailservice/mailservice.go -destination=geth/mailservice/mailservice_mock.go -package=mailservice
|
mockgen -source=geth/mailservice/mailservice.go -destination=geth/mailservice/mailservice_mock.go -package=mailservice
|
||||||
mockgen -source=geth/common/notification.go -destination=geth/common/notification_mock.go -package=common -imports fcm=github.com/NaySoftware/go-fcm
|
|
||||||
mockgen -source=geth/notifications/push/fcm/client.go -destination=geth/notifications/push/fcm/client_mock.go -package=fcm -imports fcm=github.com/NaySoftware/go-fcm
|
mockgen -source=geth/notifications/push/fcm/client.go -destination=geth/notifications/push/fcm/client_mock.go -package=fcm -imports fcm=github.com/NaySoftware/go-fcm
|
||||||
mockgen -source=geth/transactions/fake/txservice.go -destination=geth/transactions/fake/mock.go -package=fake
|
mockgen -source=geth/transactions/fake/txservice.go -destination=geth/transactions/fake/mock.go -package=fake
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ type StatusBackend struct {
|
||||||
accountManager common.AccountManager
|
accountManager common.AccountManager
|
||||||
txQueueManager *transactions.Manager
|
txQueueManager *transactions.Manager
|
||||||
jailManager jail.Manager
|
jailManager jail.Manager
|
||||||
newNotification common.NotificationConstructor
|
newNotification fcm.NotificationConstructor
|
||||||
connectionState ConnectionState
|
connectionState ConnectionState
|
||||||
log log.Logger
|
log log.Logger
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,11 +0,0 @@
|
||||||
package common
|
|
||||||
|
|
||||||
import "github.com/NaySoftware/go-fcm"
|
|
||||||
|
|
||||||
// Notifier manages Push Notifications.
|
|
||||||
type Notifier interface {
|
|
||||||
Send(body string, payload fcm.NotificationPayload, tokens ...string) error
|
|
||||||
}
|
|
||||||
|
|
||||||
// NotificationConstructor returns constructor of configured instance Notifier interface.
|
|
||||||
type NotificationConstructor func() Notifier
|
|
|
@ -1,51 +0,0 @@
|
||||||
// Code generated by MockGen. DO NOT EDIT.
|
|
||||||
// Source: geth/common/notification.go
|
|
||||||
|
|
||||||
// Package common is a generated GoMock package.
|
|
||||||
package common
|
|
||||||
|
|
||||||
import (
|
|
||||||
go_fcm "github.com/NaySoftware/go-fcm"
|
|
||||||
gomock "github.com/golang/mock/gomock"
|
|
||||||
reflect "reflect"
|
|
||||||
)
|
|
||||||
|
|
||||||
// MockNotifier is a mock of Notifier interface
|
|
||||||
type MockNotifier struct {
|
|
||||||
ctrl *gomock.Controller
|
|
||||||
recorder *MockNotifierMockRecorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// MockNotifierMockRecorder is the mock recorder for MockNotifier
|
|
||||||
type MockNotifierMockRecorder struct {
|
|
||||||
mock *MockNotifier
|
|
||||||
}
|
|
||||||
|
|
||||||
// NewMockNotifier creates a new mock instance
|
|
||||||
func NewMockNotifier(ctrl *gomock.Controller) *MockNotifier {
|
|
||||||
mock := &MockNotifier{ctrl: ctrl}
|
|
||||||
mock.recorder = &MockNotifierMockRecorder{mock}
|
|
||||||
return mock
|
|
||||||
}
|
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
|
||||||
func (m *MockNotifier) EXPECT() *MockNotifierMockRecorder {
|
|
||||||
return m.recorder
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send mocks base method
|
|
||||||
func (m *MockNotifier) Send(body string, payload go_fcm.NotificationPayload, tokens ...string) error {
|
|
||||||
varargs := []interface{}{body, payload}
|
|
||||||
for _, a := range tokens {
|
|
||||||
varargs = append(varargs, a)
|
|
||||||
}
|
|
||||||
ret := m.ctrl.Call(m, "Send", varargs...)
|
|
||||||
ret0, _ := ret[0].(error)
|
|
||||||
return ret0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send indicates an expected call of Send
|
|
||||||
func (mr *MockNotifierMockRecorder) Send(body, payload interface{}, tokens ...interface{}) *gomock.Call {
|
|
||||||
varargs := append([]interface{}{body, payload}, tokens...)
|
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Send", reflect.TypeOf((*MockNotifier)(nil).Send), varargs...)
|
|
||||||
}
|
|
|
@ -4,17 +4,24 @@ import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"github.com/NaySoftware/go-fcm"
|
"github.com/NaySoftware/go-fcm"
|
||||||
"github.com/status-im/status-go/geth/common"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Notifier manages Push Notifications.
|
||||||
|
type Notifier interface {
|
||||||
|
Send(body string, payload fcm.NotificationPayload, tokens ...string) error
|
||||||
|
}
|
||||||
|
|
||||||
|
// NotificationConstructor returns constructor of configured instance Notifier interface.
|
||||||
|
type NotificationConstructor func() Notifier
|
||||||
|
|
||||||
// Notification represents messaging provider for notifications.
|
// Notification represents messaging provider for notifications.
|
||||||
type Notification struct {
|
type Notification struct {
|
||||||
client firebaseClient
|
client firebaseClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewNotification Firebase Cloud Messaging client constructor.
|
// NewNotification Firebase Cloud Messaging client constructor.
|
||||||
func NewNotification(key string) common.NotificationConstructor {
|
func NewNotification(key string) NotificationConstructor {
|
||||||
return func() common.Notifier {
|
return func() Notifier {
|
||||||
client := fcm.NewFcmClient(key).
|
client := fcm.NewFcmClient(key).
|
||||||
SetDelayWhileIdle(true).
|
SetDelayWhileIdle(true).
|
||||||
SetContentAvailable(true).
|
SetContentAvailable(true).
|
||||||
|
|
Loading…
Reference in New Issue