mirror of
https://github.com/status-im/status-go.git
synced 2025-02-19 18:28:18 +00:00
fix(pairing): Received installation event (#3422)
This commit is contained in:
parent
2950d37e43
commit
b8209cbc7d
@ -3919,8 +3919,6 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte
|
|||||||
}
|
}
|
||||||
|
|
||||||
case protobuf.ContactUpdate:
|
case protobuf.ContactUpdate:
|
||||||
logger.Info("<<< ContactUpdate", zap.String("publicKey", senderID))
|
|
||||||
|
|
||||||
if common.IsPubKeyEqual(messageState.CurrentMessageState.PublicKey, &m.identity.PublicKey) {
|
if common.IsPubKeyEqual(messageState.CurrentMessageState.PublicKey, &m.identity.PublicKey) {
|
||||||
logger.Warn("coming from us, ignoring")
|
logger.Warn("coming from us, ignoring")
|
||||||
continue
|
continue
|
||||||
|
@ -11,6 +11,7 @@ const (
|
|||||||
EventConnectionSuccess EventType = "connection-success"
|
EventConnectionSuccess EventType = "connection-success"
|
||||||
EventTransferError EventType = "transfer-error"
|
EventTransferError EventType = "transfer-error"
|
||||||
EventTransferSuccess EventType = "transfer-success"
|
EventTransferSuccess EventType = "transfer-success"
|
||||||
|
EventReceivedInstallation EventType = "received-installation"
|
||||||
|
|
||||||
// Only Receiver side
|
// Only Receiver side
|
||||||
|
|
||||||
|
@ -298,7 +298,23 @@ func (r *InstallationPayloadStorer) Store() error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return messenger.HandleSyncRawMessages(r.payload.rawMessages)
|
|
||||||
|
installations := GetMessengerInstallationsMap(messenger)
|
||||||
|
|
||||||
|
err = messenger.HandleSyncRawMessages(r.payload.rawMessages)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if newInstallation := FindNewInstallations(messenger, installations); newInstallation != nil {
|
||||||
|
signal.SendLocalPairingEvent(Event{
|
||||||
|
Type: EventReceivedInstallation,
|
||||||
|
Action: ActionPairingInstallation,
|
||||||
|
Data: newInstallation})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -10,6 +10,8 @@ import (
|
|||||||
"github.com/status-im/status-go/multiaccounts/settings"
|
"github.com/status-im/status-go/multiaccounts/settings"
|
||||||
"github.com/status-im/status-go/params"
|
"github.com/status-im/status-go/params"
|
||||||
"github.com/status-im/status-go/protocol/protobuf"
|
"github.com/status-im/status-go/protocol/protobuf"
|
||||||
|
|
||||||
|
"github.com/status-im/status-go/signal"
|
||||||
)
|
)
|
||||||
|
|
||||||
type SyncRawMessageHandler struct {
|
type SyncRawMessageHandler struct {
|
||||||
@ -117,5 +119,21 @@ func (s *SyncRawMessageHandler) HandleRawMessage(accountPayload *AccountPayload,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return messenger.HandleSyncRawMessages(rmp.rawMessages)
|
|
||||||
|
installations := GetMessengerInstallationsMap(messenger)
|
||||||
|
|
||||||
|
err = messenger.HandleSyncRawMessages(rmp.rawMessages)
|
||||||
|
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
if newInstallation := FindNewInstallations(messenger, installations); newInstallation != nil {
|
||||||
|
signal.SendLocalPairingEvent(Event{
|
||||||
|
Type: EventReceivedInstallation,
|
||||||
|
Action: ActionPairingInstallation,
|
||||||
|
Data: newInstallation})
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
23
server/pairing/utils.go
Normal file
23
server/pairing/utils.go
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package pairing
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/status-im/status-go/protocol"
|
||||||
|
"github.com/status-im/status-go/protocol/encryption/multidevice"
|
||||||
|
)
|
||||||
|
|
||||||
|
func GetMessengerInstallationsMap(m *protocol.Messenger) map[string]struct{} {
|
||||||
|
ids := map[string]struct{}{}
|
||||||
|
for _, installation := range m.Installations() {
|
||||||
|
ids[installation.ID] = struct{}{}
|
||||||
|
}
|
||||||
|
return ids
|
||||||
|
}
|
||||||
|
|
||||||
|
func FindNewInstallations(m *protocol.Messenger, prevInstallationIds map[string]struct{}) *multidevice.Installation {
|
||||||
|
for _, installation := range m.Installations() {
|
||||||
|
if _, ok := prevInstallationIds[installation.ID]; !ok {
|
||||||
|
return installation
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user