init currentMessageState when sync protobuf.ContactUpdate (#3332)
This commit is contained in:
parent
8c85a62e10
commit
268cd72e96
|
@ -837,6 +837,7 @@ func (m *Messenger) sendContactUpdate(ctx context.Context, chatID, displayName,
|
|||
ProfileImage: profileImage,
|
||||
ContactRequestClock: contact.ContactRequestLocalClock,
|
||||
ContactRequestPropagatedState: contact.ContactRequestPropagatedState(),
|
||||
PublicKey: contact.ID,
|
||||
}
|
||||
encodedMessage, err := proto.Marshal(contactUpdate)
|
||||
if err != nil {
|
||||
|
|
|
@ -26,6 +26,32 @@ func (m *Messenger) HandleSyncRawMessages(rawMessages []*protobuf.RawMessage) er
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
publicKey, err := common.HexToPubkey(message.PublicKey)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
var contact *Contact
|
||||
if c, ok := state.AllContacts.Load(message.PublicKey); ok {
|
||||
contact = c
|
||||
} else {
|
||||
c, err := buildContact(message.PublicKey, publicKey)
|
||||
if err != nil {
|
||||
m.logger.Info("failed to build contact", zap.Error(err))
|
||||
continue
|
||||
}
|
||||
contact = c
|
||||
state.AllContacts.Store(message.PublicKey, contact)
|
||||
}
|
||||
currentMessageState := &CurrentMessageState{
|
||||
Message: protobuf.ChatMessage{
|
||||
Clock: message.Clock,
|
||||
},
|
||||
MessageID: " ", // make it not empty to bypass this validation: https://github.com/status-im/status-go/blob/7cd7430d3141b08f7c455d7918f4160ea8fd0559/protocol/messenger_handler.go#L325
|
||||
WhisperTimestamp: message.Clock,
|
||||
PublicKey: publicKey,
|
||||
Contact: contact,
|
||||
}
|
||||
state.CurrentMessageState = currentMessageState
|
||||
err = m.HandleContactUpdate(state, message)
|
||||
if err != nil {
|
||||
m.logger.Warn("failed to HandleContactUpdate when HandleSyncRawMessages", zap.Error(err))
|
||||
|
|
|
@ -90,6 +90,7 @@ type ContactUpdate struct {
|
|||
DisplayName string `protobuf:"bytes,4,opt,name=display_name,json=displayName,proto3" json:"display_name,omitempty"`
|
||||
ContactRequestClock uint64 `protobuf:"varint,5,opt,name=contact_request_clock,json=contactRequestClock,proto3" json:"contact_request_clock,omitempty"`
|
||||
ContactRequestPropagatedState *ContactRequestPropagatedState `protobuf:"bytes,6,opt,name=contact_request_propagated_state,json=contactRequestPropagatedState,proto3" json:"contact_request_propagated_state,omitempty"`
|
||||
PublicKey string `protobuf:"bytes,7,opt,name=public_key,json=publicKey,proto3" json:"public_key,omitempty"`
|
||||
XXX_NoUnkeyedLiteral struct{} `json:"-"`
|
||||
XXX_unrecognized []byte `json:"-"`
|
||||
XXX_sizecache int32 `json:"-"`
|
||||
|
@ -162,6 +163,13 @@ func (m *ContactUpdate) GetContactRequestPropagatedState() *ContactRequestPropag
|
|||
return nil
|
||||
}
|
||||
|
||||
func (m *ContactUpdate) GetPublicKey() string {
|
||||
if m != nil {
|
||||
return m.PublicKey
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
type AcceptContactRequest struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
Clock uint64 `protobuf:"varint,2,opt,name=clock,proto3" json:"clock,omitempty"`
|
||||
|
@ -268,26 +276,27 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptor_a5036fff2565fb15 = []byte{
|
||||
// 329 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x91, 0xb1, 0x4e, 0xf3, 0x30,
|
||||
0x14, 0x85, 0x95, 0xfc, 0x6d, 0xff, 0xe6, 0xa6, 0x61, 0x08, 0xad, 0x54, 0x86, 0x8a, 0x10, 0x06,
|
||||
0x3a, 0x05, 0xa9, 0x8c, 0xc0, 0x00, 0x9d, 0x58, 0x10, 0x32, 0x62, 0x61, 0x89, 0x5c, 0xe7, 0xb6,
|
||||
0x8a, 0x48, 0x62, 0xe3, 0xb8, 0x03, 0x4f, 0xc4, 0xc6, 0x33, 0xa2,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x66, 0x27, 0xeb, 0xeb, 0x20, 0xc7, 0x6c,
|
||||
0xaf, 0x50, 0x33, 0xa1, 0x80, 0xe8, 0xf7, 0x1b, 0xf1, 0xd3, 0xb4, 0x9d, 0x7a, 0x10, 0x39, 0x73,
|
||||
0x7f, 0x71, 0x91, 0xec, 0xb6, 0x93, 0x1c, 0xdc, 0x0c, 0x99, 0xb1, 0x43, 0xd7, 0xf1, 0x0d, 0x8c,
|
||||
0xef, 0x18, 0x43, 0xa1, 0xf6, 0x29, 0xe1, 0x11, 0xb8, 0x79, 0xa6, 0x3b, 0xf3, 0x88, 0x9b, 0x67,
|
||||
0x6d, 0x8d, 0x6e, 0xa7, 0xc6, 0xf8, 0x16, 0x26, 0x04, 0x95, 0xa4, 0xec, 0x4f, 0xcf, 0xef, 0x83,
|
||||
0x57, 0x3f, 0xb9, 0xbc, 0xde, 0x0d, 0xb2, 0x1a, 0xe8, 0xbf, 0xab, 0xef, 0x00, 0x00, 0x00, 0xff,
|
||||
0xff, 0xa0, 0x8b, 0xa7, 0x4a, 0x88, 0x02, 0x00, 0x00,
|
||||
// 348 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x51, 0x3f, 0x4f, 0xfb, 0x30,
|
||||
0x14, 0x54, 0xf2, 0xeb, 0xbf, 0xbc, 0x34, 0xbf, 0x21, 0xb4, 0x52, 0x19, 0x2a, 0x4a, 0x18, 0xe8,
|
||||
0x14, 0xa4, 0x32, 0x02, 0x03, 0x74, 0x42, 0x48, 0x08, 0x19, 0xb1, 0xb0, 0x44, 0xae, 0xf3, 0x5a,
|
||||
0x45, 0x4d, 0x62, 0xe3, 0xb8, 0x43, 0x3f, 0x11, 0x9f, 0x86, 0xef, 0x84, 0x62, 0xbb, 0x34, 0x65,
|
||||
0xe8, 0xc0, 0x94, 0xf8, 0x7c, 0xef, 0x7c, 0x77, 0x0f, 0x02, 0xc6, 0x4b, 0x45, 0x99, 0x8a, 0x85,
|
||||
0xe4, 0x8a, 0x87, 0x3d, 0xfd, 0x59, 0x6c, 0x96, 0xd1, 0xa7, 0x03, 0xe3, 0xb9, 0xb9, 0x23, 0xf8,
|
||||
0xb1, 0xc1, 0x4a, 0xbd, 0x48, 0x2e, 0xe8, 0x8a, 0x2a, 0x4c, 0x5f, 0x15, 0x55, 0x18, 0x9e, 0x81,
|
||||
0x9f, 0x73, 0x46, 0xf3, 0x84, 0xe5, 0x9c, 0xad, 0x47, 0xce, 0xc4, 0x99, 0xb6, 0x08, 0x68, 0x68,
|
||||
0x5e, 0x23, 0x7b, 0x42, 0x55, 0xf3, 0x47, 0x6e, 0x83, 0x60, 0x14, 0xce, 0xa1, 0x2f, 0xb1, 0xe0,
|
||||
0x0a, 0xad, 0xc4, 0x3f, 0xcd, 0xf0, 0x0d, 0x66, 0x34, 0xf6, 0x14, 0x23, 0xd2, 0x6a, 0x52, 0xb4,
|
||||
0x4a, 0xf4, 0xe5, 0x42, 0x60, 0x9d, 0xbe, 0x89, 0xb4, 0xd6, 0x1d, 0x40, 0xbb, 0xe9, 0xc9, 0x1c,
|
||||
0xc2, 0x53, 0xe8, 0x61, 0x59, 0x25, 0x25, 0x2d, 0x8c, 0x17, 0x8f, 0x74, 0xb1, 0xac, 0x9e, 0x69,
|
||||
0x81, 0xe1, 0x05, 0x04, 0x42, 0xf2, 0x65, 0x96, 0x63, 0x92, 0x15, 0x74, 0x85, 0xda, 0x89, 0x47,
|
||||
0xfa, 0x16, 0x7c, 0xac, 0xb1, 0xda, 0x4a, 0x9a, 0x55, 0x22, 0xa7, 0x5b, 0xa3, 0xd1, 0xd2, 0x1c,
|
||||
0xdf, 0x62, 0x5a, 0x67, 0x06, 0x43, 0xdb, 0x67, 0x22, 0x4d, 0x69, 0x36, 0x59, 0x5b, 0x1b, 0x39,
|
||||
0x61, 0x07, 0x85, 0x9a, 0x84, 0x02, 0x26, 0xbf, 0x67, 0xc4, 0x4f, 0xd3, 0x36, 0x75, 0x67, 0xe2,
|
||||
0x4c, 0xfd, 0xd9, 0x65, 0xbc, 0xdb, 0x4e, 0x7c, 0x74, 0x33, 0x64, 0xcc, 0x8e, 0x2e, 0x6e, 0x0c,
|
||||
0x20, 0x36, 0x8b, 0x3c, 0x63, 0xc9, 0x1a, 0xb7, 0xa3, 0xae, 0x8e, 0xe1, 0x19, 0xe4, 0x09, 0xb7,
|
||||
0xd1, 0x2d, 0x0c, 0xee, 0x19, 0x43, 0xa1, 0x0e, 0x1f, 0x09, 0xff, 0x83, 0x9b, 0xa5, 0xba, 0x52,
|
||||
0x8f, 0xb8, 0x59, 0xba, 0x6f, 0xd9, 0x6d, 0xb4, 0x1c, 0xdd, 0xc1, 0x90, 0xa0, 0x92, 0x94, 0xfd,
|
||||
0x69, 0xfc, 0x21, 0x78, 0xf7, 0xe3, 0xab, 0x9b, 0x5d, 0xce, 0x45, 0x47, 0xff, 0x5d, 0x7f, 0x07,
|
||||
0x00, 0x00, 0xff, 0xff, 0xec, 0x6f, 0x01, 0xce, 0xa7, 0x02, 0x00, 0x00,
|
||||
}
|
||||
|
|
|
@ -17,6 +17,7 @@ message ContactUpdate {
|
|||
string display_name = 4;
|
||||
uint64 contact_request_clock = 5;
|
||||
ContactRequestPropagatedState contact_request_propagated_state = 6;
|
||||
string public_key = 7;
|
||||
}
|
||||
|
||||
message AcceptContactRequest {
|
||||
|
|
|
@ -5,10 +5,10 @@ import (
|
|||
)
|
||||
|
||||
// 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
|
||||
// - receive and prepare encrypted transport data (PayloadReceiver.Receive) to be stored
|
||||
// - prepare the received (PayloadReceiver.Received) data to be stored to a PayloadRepository or a PayloadStorer
|
||||
// - mount payload data from a PayloadRepository or a PayloadLoader into memory (PayloadMounter.Mount)
|
||||
// - prepare data to be sent encrypted (PayloadMounter.ToSend) via some transport
|
||||
// - receive and prepare encrypted transport data (PayloadReceiver.Receive) to be stored
|
||||
// - prepare the received (PayloadReceiver.Received) data to be stored to a PayloadRepository or a PayloadStorer
|
||||
type PayloadMounterReceiver interface {
|
||||
PayloadMounter
|
||||
PayloadReceiver
|
||||
|
|
|
@ -164,9 +164,8 @@ func (s *ServerURLSuite) TestQRCodeGeneration() {
|
|||
_ = rootCAs.AppendCertsFromPEM(certPem)
|
||||
tr := &http.Transport{
|
||||
TLSClientConfig: &tls.Config{
|
||||
MinVersion: tls.VersionTLS12,
|
||||
InsecureSkipVerify: true, //nolint:all // MUST BE FALSE
|
||||
RootCAs: rootCAs,
|
||||
MinVersion: tls.VersionTLS12,
|
||||
RootCAs: rootCAs,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue