diff --git a/VERSION b/VERSION index c6915b0c1..5edc0a741 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.147.1 +0.148.0 diff --git a/protocol/messenger.go b/protocol/messenger.go index d095dbc0c..80a2c5f82 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -3919,8 +3919,6 @@ func (m *Messenger) handleRetrievedMessages(chatWithMessages map[transport.Filte } case protobuf.ContactUpdate: - logger.Info("<<< ContactUpdate", zap.String("publicKey", senderID)) - if common.IsPubKeyEqual(messageState.CurrentMessageState.PublicKey, &m.identity.PublicKey) { logger.Warn("coming from us, ignoring") continue diff --git a/server/pairing/events.go b/server/pairing/events.go index 6d8a5197e..2e1203ae5 100644 --- a/server/pairing/events.go +++ b/server/pairing/events.go @@ -6,11 +6,12 @@ type EventType string const ( // Both Sender and Receiver - EventPeerDiscovered EventType = "peer-discovered" - EventConnectionError EventType = "connection-error" - EventConnectionSuccess EventType = "connection-success" - EventTransferError EventType = "transfer-error" - EventTransferSuccess EventType = "transfer-success" + EventPeerDiscovered EventType = "peer-discovered" + EventConnectionError EventType = "connection-error" + EventConnectionSuccess EventType = "connection-success" + EventTransferError EventType = "transfer-error" + EventTransferSuccess EventType = "transfer-success" + EventReceivedInstallation EventType = "received-installation" // Only Receiver side diff --git a/server/pairing/payload_receiver.go b/server/pairing/payload_receiver.go index c5fa30605..267beb663 100644 --- a/server/pairing/payload_receiver.go +++ b/server/pairing/payload_receiver.go @@ -298,7 +298,23 @@ func (r *InstallationPayloadStorer) Store() error { if err != nil { 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 } /* diff --git a/server/pairing/raw_message_handler.go b/server/pairing/raw_message_handler.go index 081005ec3..507837a57 100644 --- a/server/pairing/raw_message_handler.go +++ b/server/pairing/raw_message_handler.go @@ -10,6 +10,8 @@ import ( "github.com/status-im/status-go/multiaccounts/settings" "github.com/status-im/status-go/params" "github.com/status-im/status-go/protocol/protobuf" + + "github.com/status-im/status-go/signal" ) type SyncRawMessageHandler struct { @@ -117,5 +119,21 @@ func (s *SyncRawMessageHandler) HandleRawMessage(accountPayload *AccountPayload, if err != nil { 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 } diff --git a/server/pairing/utils.go b/server/pairing/utils.go new file mode 100644 index 000000000..36657acc2 --- /dev/null +++ b/server/pairing/utils.go @@ -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 +}