parent
465afd0131
commit
170ae0d455
|
@ -23,8 +23,7 @@ const (
|
|||
|
||||
// Account handling
|
||||
|
||||
func handleReceiveAccount(hs HandlerServer, pr PayloadReceiver) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handleReceiveAccount(logger *zap.Logger, pr PayloadReceiver) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingAccount})
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
|
@ -47,8 +46,7 @@ func handleReceiveAccount(hs HandlerServer, pr PayloadReceiver) http.HandlerFunc
|
|||
}
|
||||
}
|
||||
|
||||
func handleSendAccount(hs HandlerServer, pm PayloadMounter) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handleSendAccount(logger *zap.Logger, pm PayloadMounter) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingAccount})
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
|
@ -75,8 +73,7 @@ func handleSendAccount(hs HandlerServer, pm PayloadMounter) http.HandlerFunc {
|
|||
|
||||
// Device sync handling
|
||||
|
||||
func handleParingSyncDeviceReceive(hs HandlerServer, pr PayloadReceiver) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handleParingSyncDeviceReceive(logger *zap.Logger, pr PayloadReceiver) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionSyncDevice})
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
|
@ -99,8 +96,7 @@ func handleParingSyncDeviceReceive(hs HandlerServer, pr PayloadReceiver) http.Ha
|
|||
}
|
||||
}
|
||||
|
||||
func handlePairingSyncDeviceSend(hs HandlerServer, pm PayloadMounter) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handlePairingSyncDeviceSend(logger *zap.Logger, pm PayloadMounter) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionSyncDevice})
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
|
@ -129,8 +125,7 @@ func handlePairingSyncDeviceSend(hs HandlerServer, pm PayloadMounter) http.Handl
|
|||
|
||||
// Installation data handling
|
||||
|
||||
func handleReceiveInstallation(hs HandlerServer, pmr PayloadMounterReceiver) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handleReceiveInstallation(logger *zap.Logger, pmr PayloadMounterReceiver) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingInstallation})
|
||||
payload, err := io.ReadAll(r.Body)
|
||||
|
@ -153,8 +148,7 @@ func handleReceiveInstallation(hs HandlerServer, pmr PayloadMounterReceiver) htt
|
|||
}
|
||||
}
|
||||
|
||||
func handleSendInstallation(hs HandlerServer, pmr PayloadMounterReceiver) http.HandlerFunc {
|
||||
logger := hs.GetLogger()
|
||||
func handleSendInstallation(logger *zap.Logger, pmr PayloadMounterReceiver) http.HandlerFunc {
|
||||
return func(w http.ResponseWriter, r *http.Request) {
|
||||
signal.SendLocalPairingEvent(Event{Type: EventConnectionSuccess, Action: ActionPairingInstallation})
|
||||
w.Header().Set("Content-Type", "application/octet-stream")
|
||||
|
|
|
@ -1,9 +1,5 @@
|
|||
package pairing
|
||||
|
||||
import (
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
// PayloadMounterReceiver represents a struct that can:
|
||||
// - mount payload data from a PayloadRepository or a PayloadLoader into memory (PayloadMounter.Mount)
|
||||
// - prepare data to be sent encrypted (PayloadMounter.ToSend) via some transport
|
||||
|
@ -25,14 +21,6 @@ type PayloadLocker interface {
|
|||
LockPayload()
|
||||
}
|
||||
|
||||
// TODO if this interface only gets a logger, then maybe remove the interface and change consuming function params
|
||||
// to accept a *zap.logger
|
||||
// https://github.com/status-im/status-go/issues/3370
|
||||
|
||||
type HandlerServer interface {
|
||||
GetLogger() *zap.Logger
|
||||
}
|
||||
|
||||
type ProtobufMarshaller interface {
|
||||
MarshalProtobuf() ([]byte, error)
|
||||
}
|
||||
|
|
|
@ -142,13 +142,13 @@ func NewSenderServer(backend *api.GethStatusBackend, config *SenderServerConfig)
|
|||
func (s *SenderServer) startSendingData() error {
|
||||
s.SetHandlers(server.HandlerPatternMap{
|
||||
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
||||
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(s, s.accountMounter)),
|
||||
pairingSendSyncDevice: middlewareChallenge(s.challengeGiver, handlePairingSyncDeviceSend(s, s.rawMessageMounter)),
|
||||
pairingSendAccount: middlewareChallenge(s.challengeGiver, handleSendAccount(s.GetLogger(), s.accountMounter)),
|
||||
pairingSendSyncDevice: middlewareChallenge(s.challengeGiver, handlePairingSyncDeviceSend(s.GetLogger(), s.rawMessageMounter)),
|
||||
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
||||
// the other handlers.
|
||||
// https://github.com/status-im/status-go/issues/3304
|
||||
// receive installation data from receiver
|
||||
pairingReceiveInstallation: middlewareChallenge(s.challengeGiver, handleReceiveInstallation(s, s.installationMounter)),
|
||||
pairingReceiveInstallation: middlewareChallenge(s.challengeGiver, handleReceiveInstallation(s.GetLogger(), s.installationMounter)),
|
||||
})
|
||||
return s.Start()
|
||||
}
|
||||
|
@ -237,13 +237,13 @@ func NewReceiverServer(backend *api.GethStatusBackend, config *ReceiverServerCon
|
|||
func (s *ReceiverServer) startReceivingData() error {
|
||||
s.SetHandlers(server.HandlerPatternMap{
|
||||
pairingChallenge: handlePairingChallenge(s.challengeGiver),
|
||||
pairingReceiveAccount: handleReceiveAccount(s, s.accountReceiver),
|
||||
pairingReceiveSyncDevice: handleParingSyncDeviceReceive(s, s.rawMessageReceiver),
|
||||
pairingReceiveAccount: handleReceiveAccount(s.GetLogger(), s.accountReceiver),
|
||||
pairingReceiveSyncDevice: handleParingSyncDeviceReceive(s.GetLogger(), s.rawMessageReceiver),
|
||||
// TODO implement refactor of installation data exchange to follow the send/receive pattern of
|
||||
// the other handlers.
|
||||
// https://github.com/status-im/status-go/issues/3304
|
||||
// send installation data back to sender
|
||||
pairingSendInstallation: middlewareChallenge(s.challengeGiver, handleSendInstallation(s, s.installationReceiver)),
|
||||
pairingSendInstallation: middlewareChallenge(s.challengeGiver, handleSendInstallation(s.GetLogger(), s.installationReceiver)),
|
||||
})
|
||||
return s.Start()
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue