diff --git a/protocol/message_validator.go b/protocol/message_validator.go index e4f8e0442..6530b31df 100644 --- a/protocol/message_validator.go +++ b/protocol/message_validator.go @@ -303,8 +303,10 @@ func ValidateReceivedChatMessage(message *protobuf.ChatMessage, whisperTimestamp return errors.New("private group system message content type not allowed") } - if message.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE { - return errors.New("mutual state update system message content type not allowed") + if message.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT || + message.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED || + message.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED { + return errors.New("mutual state event system message content type not allowed") } if err := ValidateDisplayName(&message.DisplayName); err != nil { diff --git a/protocol/messenger_backup_test.go b/protocol/messenger_backup_test.go index e45d33147..27889fb41 100644 --- a/protocol/messenger_backup_test.go +++ b/protocol/messenger_backup_test.go @@ -468,7 +468,7 @@ func (s *MessengerBackupSuite) TestBackupContactsGreaterThanBatch() { ) s.Require().NoError(err) - s.Require().Less(BackupContactsPerBatch*2, len(bob2.Contacts())) + s.Require().Equal(BackupContactsPerBatch*2, len(bob2.Contacts())) s.Require().Len(bob2.AddedContacts(), BackupContactsPerBatch*2) } diff --git a/protocol/messenger_contact_requests_test.go b/protocol/messenger_contact_requests_test.go index 51a7c3fa6..036bdf022 100644 --- a/protocol/messenger_contact_requests_test.go +++ b/protocol/messenger_contact_requests_test.go @@ -3,6 +3,7 @@ package protocol import ( "context" "crypto/ecdsa" + "fmt" "testing" "github.com/stretchr/testify/suite" @@ -74,18 +75,19 @@ func (s *MessengerContactRequestSuite) sendContactRequest(request *requests.Send // Check CR and mutual state update messages s.Require().Len(resp.Messages(), 2) - contactRequest := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) - s.Require().NotNil(contactRequest) - - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) + mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT) s.Require().NotNil(mutualStateUpdate) - s.Require().Equal(common.ContactRequestStatePending, contactRequest.ContactRequestState) - s.Require().Equal(request.Message, contactRequest.Text) s.Require().NotNil(mutualStateUpdate.ID) s.Require().Equal(mutualStateUpdate.From, messenger.myHexIdentity()) s.Require().Equal(mutualStateUpdate.ChatId, request.ID) - s.Require().Equal(mutualStateUpdate.Text, "You sent a contact request to @"+request.ID) + s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(outgoingMutualStateEventSentDefaultText, request.ID)) + + contactRequest := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) + s.Require().NotNil(contactRequest) + + s.Require().Equal(common.ContactRequestStatePending, contactRequest.ContactRequestState) + s.Require().Equal(request.Message, contactRequest.Text) // Check pending notification s.Require().Len(resp.ActivityCenterNotifications(), 1) @@ -112,13 +114,6 @@ func (s *MessengerContactRequestSuite) sendContactRequest(request *requests.Send // Check contact's primary name matches notifiaction's name s.Require().Equal(resp.ActivityCenterNotifications()[0].Name, contacts[0].PrimaryName()) - - // Make sure update message was saved properly - mutualStateUpdateFromDb, err := messenger.persistence.MessageByID(mutualStateUpdate.ID) - s.Require().NoError(err) - s.Require().Equal(mutualStateUpdateFromDb.From, messenger.myHexIdentity()) - s.Require().Equal(mutualStateUpdateFromDb.ChatId, request.ID) - s.Require().Equal(mutualStateUpdateFromDb.Text, "You sent a contact request to @"+request.ID) } func (s *MessengerContactRequestSuite) receiveContactRequest(messageText string, theirMessenger *Messenger) *common.Message { @@ -126,7 +121,7 @@ func (s *MessengerContactRequestSuite) receiveContactRequest(messageText string, resp, err := WaitOnMessengerResponse( theirMessenger, func(r *MessengerResponse) bool { - return len(r.Contacts) == 1 && len(r.Messages()) == 2 && len(r.ActivityCenterNotifications()) == 1 + return len(r.Contacts) == 1 && len(r.Messages()) >= 2 && len(r.ActivityCenterNotifications()) == 1 }, "no messages", ) @@ -141,14 +136,15 @@ func (s *MessengerContactRequestSuite) receiveContactRequest(messageText string, contactRequest := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequest) - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) - s.Require().NotNil(mutualStateUpdate) - s.Require().Equal(common.ContactRequestStatePending, contactRequest.ContactRequestState) s.Require().Equal(messageText, contactRequest.Text) + + mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT) + s.Require().NotNil(mutualStateUpdate) + s.Require().Equal(mutualStateUpdate.From, contactRequest.From) s.Require().Equal(mutualStateUpdate.ChatId, contactRequest.From) - s.Require().Equal(mutualStateUpdate.Text, "@"+contactRequest.From+" sent you a contact request") + s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(incomingMutualStateEventSentDefaultText, contactRequest.From)) // Check activity center notification is of the right type s.Require().Len(resp.ActivityCenterNotifications(), 1) @@ -200,15 +196,15 @@ func (s *MessengerContactRequestSuite) acceptContactRequest(contactRequest *comm contactRequestMsg := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequestMsg) - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) + mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED) s.Require().NotNil(mutualStateUpdate) s.Require().Equal(contactRequestMsg.ID, contactRequest.ID) s.Require().Equal(common.ContactRequestStateAccepted, contactRequestMsg.ContactRequestState) - // Reversed for add contact update - s.Require().Equal(mutualStateUpdate.From, contactRequestMsg.ChatId) + s.Require().Equal(mutualStateUpdate.ChatId, contactRequestMsg.From) - s.Require().Equal(mutualStateUpdate.Text, "You added @"+contactRequestMsg.From+" as a contact") + s.Require().Equal(mutualStateUpdate.From, contactRequestMsg.ChatId) + s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(outgoingMutualStateEventAcceptedDefaultText, contactRequestMsg.From)) s.Require().Len(resp.ActivityCenterNotifications(), 1) s.Require().Equal(resp.ActivityCenterNotifications()[0].ID.String(), contactRequest.ID) @@ -260,7 +256,7 @@ func (s *MessengerContactRequestSuite) acceptContactRequest(contactRequest *comm contactRequestMsg = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequestMsg) - mutualStateUpdate = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) + mutualStateUpdate = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED) s.Require().NotNil(mutualStateUpdate) s.Require().Equal(contactRequest.ID, contactRequestMsg.ID) @@ -269,7 +265,7 @@ func (s *MessengerContactRequestSuite) acceptContactRequest(contactRequest *comm s.Require().Equal(mutualStateUpdate.From, contactRequestMsg.ChatId) s.Require().Equal(mutualStateUpdate.ChatId, contactRequestMsg.ChatId) - s.Require().Equal(mutualStateUpdate.Text, "@"+mutualStateUpdate.From+" added you as a contact") + s.Require().Equal(mutualStateUpdate.Text, fmt.Sprintf(incomingMutualStateEventAcceptedDefaultText, contactRequestMsg.ChatId)) // Make sure we consider them a mutual contact, sender side mutualContacts = s.m.MutualContacts() @@ -474,13 +470,8 @@ func (s *MessengerContactRequestSuite) TestReceiveAndAcceptContactRequestTwice() contactRequest = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequest) - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) - s.Require().NotNil(mutualStateUpdate) - s.Require().Equal(common.ContactRequestStateAccepted, contactRequest.ContactRequestState) s.Require().Equal(request.Message, contactRequest.Text) - s.Require().Equal(mutualStateUpdate.From, s.m.myHexIdentity()) - s.Require().Equal(mutualStateUpdate.ChatId, request.ID) // Wait for the message to reach its destination resp, err = WaitOnMessengerResponse( @@ -536,7 +527,7 @@ func (s *MessengerContactRequestSuite) TestAcceptLatestContactRequestForContact( contactRequestMsg := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequestMsg) - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) + mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED) s.Require().NotNil(mutualStateUpdate) s.Require().Equal(contactRequestMsg.ID, contactRequest.ID) @@ -580,7 +571,7 @@ func (s *MessengerContactRequestSuite) TestAcceptLatestContactRequestForContact( contactRequestMsg = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequestMsg) - mutualStateUpdate = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) + mutualStateUpdate = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED) s.Require().NotNil(mutualStateUpdate) s.Require().Equal(common.ContactRequestStateAccepted, contactRequestMsg.ContactRequestState) @@ -1068,15 +1059,9 @@ func (s *MessengerContactRequestSuite) TestBobSendsContactRequestAfterDecliningO contactRequest = s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_CONTACT_REQUEST) s.Require().NotNil(contactRequest) - mutualStateUpdate := s.findFirstByContentType(resp.Messages(), protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE) - s.Require().NotNil(mutualStateUpdate) - s.Require().Equal(common.ContactRequestStateAccepted, contactRequest.ContactRequestState) s.Require().Equal(requestFromBob.Message, contactRequest.Text) - s.Require().Equal(mutualStateUpdate.From, contactRequest.From) - s.Require().Equal(mutualStateUpdate.ChatId, contactRequest.ChatId) - // Check pending notification s.Require().Len(resp.ActivityCenterNotifications(), 1) s.Require().Equal(ActivityCenterNotificationTypeContactRequest, resp.ActivityCenterNotifications()[0].Type) @@ -1141,7 +1126,10 @@ func (s *MessengerContactRequestSuite) TestBobSendsContactRequestAfterDecliningO } func (s *MessengerContactRequestSuite) TestBuildContact() { - contactID := types.EncodeHex(crypto.FromECDSAPub(&s.m.identity.PublicKey)) + contactKey, err := crypto.GenerateKey() + s.Require().NoError(err) + contactID := types.EncodeHex(crypto.FromECDSAPub(&contactKey.PublicKey)) + contact, err := s.m.BuildContact(&requests.BuildContact{PublicKey: contactID}) s.Require().NoError(err) diff --git a/protocol/messenger_contacts.go b/protocol/messenger_contacts.go index fd8ba8969..3e086ddc2 100644 --- a/protocol/messenger_contacts.go +++ b/protocol/messenger_contacts.go @@ -18,21 +18,32 @@ import ( "github.com/status-im/status-go/protocol/transport" ) +const outgoingMutualStateEventSentDefaultText = "You sent a contact request to @%s" +const outgoingMutualStateEventAcceptedDefaultText = "You accepted @%s's contact request" +const outgoingMutualStateEventRemovedDefaultText = "You removed @%s as a contact" +const incomingMutualStateEventSentDefaultText = "@%s sent you a contact request" +const incomingMutualStateEventAcceptedDefaultText = "@%s accepted your contact request" +const incomingMutualStateEventRemovedDefaultText = "@%s removed you as a contact" + func (m *Messenger) prepareMutualStateUpdateMessage(contactID string, updateType MutualStateUpdateType, clock uint64, timestamp uint64, outgoing bool) (*common.Message, error) { var text string var to string var from string + var contentType protobuf.ChatMessage_ContentType if outgoing { to = contactID from = m.myHexIdentity() switch updateType { case MutualStateUpdateTypeSent: - text = "You sent a contact request to @" + to + text = fmt.Sprintf(outgoingMutualStateEventSentDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT case MutualStateUpdateTypeAdded: - text = "You added @" + to + " as a contact" + text = fmt.Sprintf(outgoingMutualStateEventAcceptedDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED case MutualStateUpdateTypeRemoved: - text = "You removed @" + to + " as a contact" + text = fmt.Sprintf(outgoingMutualStateEventRemovedDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED default: return nil, fmt.Errorf("unhandled outgoing MutualStateUpdateType = %d", updateType) } @@ -42,11 +53,14 @@ func (m *Messenger) prepareMutualStateUpdateMessage(contactID string, updateType switch updateType { case MutualStateUpdateTypeSent: - text = "@" + from + " sent you a contact request" + text = fmt.Sprintf(incomingMutualStateEventSentDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT case MutualStateUpdateTypeAdded: - text = "@" + from + " added you as a contact" + text = fmt.Sprintf(incomingMutualStateEventAcceptedDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED case MutualStateUpdateTypeRemoved: - text = "@" + from + " removed you as a contact" + text = fmt.Sprintf(incomingMutualStateEventRemovedDefaultText, contactID) + contentType = protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED default: return nil, fmt.Errorf("unhandled incoming MutualStateUpdateType = %d", updateType) } @@ -57,7 +71,7 @@ func (m *Messenger) prepareMutualStateUpdateMessage(contactID string, updateType ChatId: contactID, Text: text, MessageType: protobuf.MessageType_ONE_TO_ONE, - ContentType: protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE, + ContentType: contentType, Clock: clock, Timestamp: timestamp, }, @@ -71,27 +85,6 @@ func (m *Messenger) prepareMutualStateUpdateMessage(contactID string, updateType return message, nil } -func (m *Messenger) removeLastMutualStateUpdateMessage(response *MessengerResponse, contactID string) error { - messages, _, err := m.MessageByChatID(contactID, "", 5) - if err != nil { - return err - } - - for _, message := range messages { - if message.ContentType == protobuf.ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE { - message.Deleted = true - message.DeletedBy = m.myHexIdentity() - err = m.persistence.SaveMessages([]*common.Message{message}) - if err != nil { - return err - } - response.AddMessage(message) - response.AddRemovedMessage(&RemovedMessage{MessageID: message.ID, ChatID: contactID, DeletedBy: m.myHexIdentity()}) - } - } - return nil -} - func (m *Messenger) acceptContactRequest(ctx context.Context, requestID string, syncing bool) (*MessengerResponse, error) { contactRequest, err := m.persistence.MessageByID(requestID) if err != nil { @@ -123,26 +116,6 @@ func (m *Messenger) acceptContactRequest(ctx context.Context, requestID string, } response.AddChat(chat) - // Remove last sent system message - err = m.removeLastMutualStateUpdateMessage(response, contactRequest.From) - if err != nil { - return nil, err - } - - // System message for mutual state update - clock, timestamp := chat.NextClockAndTimestamp(m.getTimesource()) - updateMessage, err := m.prepareMutualStateUpdateMessage(contactRequest.From, MutualStateUpdateTypeAdded, clock, timestamp, true) - if err != nil { - return nil, err - } - - m.prepareMessage(updateMessage, m.httpServer) - err = m.persistence.SaveMessages([]*common.Message{updateMessage}) - if err != nil { - return nil, err - } - response.AddMessage(updateMessage) - return response, nil } @@ -289,11 +262,17 @@ func (m *Messenger) updateAcceptedContactRequest(response *MessengerResponse, co return nil, errors.New("failed to update contact request: contact not found") } - _, clock, err := m.getOneToOneAndNextClock(contact) + chat, ok := m.allChats.Load(contact.ID) + if !ok { + return nil, errors.New("no chat found for accepted contact request") + } + + notification, err := m.persistence.GetActivityCenterNotificationByID(types.FromHex(contactRequest.ID)) if err != nil { return nil, err } + clock, _ := chat.NextClockAndTimestamp(m.transport) contact.AcceptContactRequest(clock) acceptContactRequest := &protobuf.AcceptContactRequest{ @@ -315,11 +294,6 @@ func (m *Messenger) updateAcceptedContactRequest(response *MessengerResponse, co return nil, err } - notification, err := m.persistence.GetActivityCenterNotificationByID(types.FromHex(contactRequest.ID)) - if err != nil { - return nil, err - } - if response == nil { response = &MessengerResponse{} } @@ -341,19 +315,9 @@ func (m *Messenger) updateAcceptedContactRequest(response *MessengerResponse, co response.AddMessage(contactRequest) response.AddContact(contact) - // Remove last sent system message - err = m.removeLastMutualStateUpdateMessage(response, contact.ID) - if err != nil { - return nil, err - } - - // System message for mutual state update - chat, clock, err := m.getOneToOneAndNextClock(contact) - if err != nil { - return nil, err - } - timestamp := m.getTimesource().GetCurrentTime() - updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeAdded, clock, timestamp, false) + // Add mutual state update message for incoming contact request + clock, timestamp := chat.NextClockAndTimestamp(m.transport) + updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeAdded, clock, timestamp, true) if err != nil { return nil, err } @@ -375,7 +339,9 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d return nil, err } - _, clock, err := m.getOneToOneAndNextClock(contact) + response := &MessengerResponse{} + + chat, clock, err := m.getOneToOneAndNextClock(contact) if err != nil { return nil, err } @@ -464,8 +430,6 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d return nil, err } - response := &MessengerResponse{} - if sendContactUpdate { response, err = m.sendContactUpdate(context.Background(), pubKey, displayName, ensName, "", m.dispatchMessage) if err != nil { @@ -484,16 +448,6 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d } } - // Send profile picture with contact request - chat, ok := m.allChats.Load(contact.ID) - if !ok { - chat = OneToOneFromPublicKey(publicKey, m.getTimesource()) - chat.Active = false - if err := m.saveChat(chat); err != nil { - return nil, err - } - } - // Sends a standalone ChatIdentity message err = m.handleStandaloneChatIdentity(chat) if err != nil { @@ -514,6 +468,23 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d return nil, err } + // Add mutual state update message for outgoing contact request + if len(contactRequestID) == 0 { + clock, timestamp := chat.NextClockAndTimestamp(m.transport) + updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeSent, clock, timestamp, true) + if err != nil { + return nil, err + } + + m.prepareMessage(updateMessage, m.httpServer) + err = m.persistence.SaveMessages([]*common.Message{updateMessage}) + if err != nil { + return nil, err + } + response.AddMessage(updateMessage) + response.AddChat(chat) + } + // Add outgoing contact request notification if createOutgoingContactRequestNotification { clock, timestamp := chat.NextClockAndTimestamp(m.transport) @@ -533,21 +504,6 @@ func (m *Messenger) addContact(ctx context.Context, pubKey, ensName, nickname, d return nil, err } - // System message for mutual state update - clock, timestamp = chat.NextClockAndTimestamp(m.transport) - updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeSent, clock, timestamp, true) - if err != nil { - return nil, err - } - - m.prepareMessage(updateMessage, m.httpServer) - err = m.persistence.SaveMessages([]*common.Message{updateMessage}) - if err != nil { - return nil, err - } - response.AddMessage(updateMessage) - response.AddChat(chat) - notification := m.generateOutgoingContactRequestNotification(contact, contactRequest) err = m.addActivityCenterNotification(response, notification) if err != nil { @@ -663,11 +619,6 @@ func (m *Messenger) removeContact(ctx context.Context, response *MessengerRespon response.AddChat(chat) // Next we retract a contact request - _, clock, err = m.getOneToOneAndNextClock(contact) - if err != nil { - return err - } - contact.RetractContactRequest(clock) contact.LastUpdatedLocally = m.getTimesource().GetCurrentTime() diff --git a/protocol/messenger_handler.go b/protocol/messenger_handler.go index 28ca46d3f..3a20ccb0a 100644 --- a/protocol/messenger_handler.go +++ b/protocol/messenger_handler.go @@ -354,36 +354,6 @@ func (m *Messenger) createIncomingContactRequestNotification(contact *Contact, m return m.addActivityCenterNotification(messageState.Response, notification) } -func (m *Messenger) createIncomingContactRequestEventAndNotification(contact *Contact, messageState *ReceivedMessageState, contactRequest *common.Message, createNewNotification bool) error { - var updateType MutualStateUpdateType - if contactRequest.ContactRequestState == common.ContactRequestStateAccepted { - updateType = MutualStateUpdateTypeAdded - } else { - updateType = MutualStateUpdateTypeSent - } - - // System message for mutual state update - chat, clock, err := m.getOneToOneAndNextClock(contact) - if err != nil { - return err - } - timestamp := m.getTimesource().GetCurrentTime() - updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, updateType, clock, timestamp, false) - if err != nil { - return err - } - - m.prepareMessage(updateMessage, m.httpServer) - err = m.persistence.SaveMessages([]*common.Message{updateMessage}) - if err != nil { - return err - } - messageState.Response.AddMessage(updateMessage) - messageState.Response.AddChat(chat) - - return m.createIncomingContactRequestNotification(contact, messageState, contactRequest, createNewNotification) -} - func (m *Messenger) handleCommandMessage(state *ReceivedMessageState, message *common.Message) error { message.ID = state.CurrentMessageState.MessageID message.From = state.CurrentMessageState.Contact.ID @@ -492,7 +462,7 @@ func (m *Messenger) syncContactRequestForInstallationContact(contact *Contact, s return err } } else { - err = m.createIncomingContactRequestEventAndNotification(contact, state, contactRequest, true) + err = m.createIncomingContactRequestNotification(contact, state, contactRequest, true) if err != nil { return err } @@ -953,6 +923,21 @@ func (m *Messenger) handleAcceptContactRequestMessage(state *ReceivedMessageStat chat.Active = true } + // Add mutual state update message for incoming contact request + clock, timestamp := chat.NextClockAndTimestamp(m.transport) + + updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeAdded, clock, timestamp, false) + if err != nil { + return err + } + + m.prepareMessage(updateMessage, m.httpServer) + err = m.persistence.SaveMessages([]*common.Message{updateMessage}) + if err != nil { + return err + } + state.Response.AddMessage(updateMessage) + state.Response.AddChat(chat) state.AllChats.Store(chat.ID, chat) } @@ -965,7 +950,7 @@ func (m *Messenger) handleAcceptContactRequestMessage(state *ReceivedMessageStat return err } } else { - err = m.createIncomingContactRequestEventAndNotification(contact, state, request, processingResponse.newContactRequestReceived) + err = m.createIncomingContactRequestNotification(contact, state, request, processingResponse.newContactRequestReceived) if err != nil { return err } @@ -1100,7 +1085,7 @@ func (m *Messenger) HandleContactUpdate(state *ReceivedMessageState, message pro return err } - err = m.createIncomingContactRequestEventAndNotification(contact, state, contactRequest, true) + err = m.createIncomingContactRequestNotification(contact, state, contactRequest, true) if err != nil { return err } @@ -1109,7 +1094,6 @@ func (m *Messenger) HandleContactUpdate(state *ReceivedMessageState, message pro logger.Debug("handled propagated state", zap.Any("state after update", contact.ContactRequestPropagatedState())) state.ModifiedContacts.Store(contact.ID, true) state.AllContacts.Store(contact.ID, contact) - } if contact.LastUpdated < message.Clock { @@ -1124,7 +1108,7 @@ func (m *Messenger) HandleContactUpdate(state *ReceivedMessageState, message pro r := contact.ContactRequestReceived(message.ContactRequestClock) if r.newContactRequestReceived { - err = m.createIncomingContactRequestEventAndNotification(contact, state, nil, true) + err = m.createIncomingContactRequestNotification(contact, state, nil, true) if err != nil { return err } @@ -2098,7 +2082,21 @@ func (m *Messenger) handleChatMessage(state *ReceivedMessageState, forceSeen boo receivedMessage.ContactRequestState = common.ContactRequestStatePending } - err = m.createIncomingContactRequestEventAndNotification(contact, state, receivedMessage, true) + // Add mutual state update message for outgoing contact request + clock := receivedMessage.Clock - 1 + updateMessage, err := m.prepareMutualStateUpdateMessage(contact.ID, MutualStateUpdateTypeSent, clock, receivedMessage.Timestamp, false) + if err != nil { + return err + } + + m.prepareMessage(updateMessage, m.httpServer) + err = m.persistence.SaveMessages([]*common.Message{updateMessage}) + if err != nil { + return err + } + state.Response.AddMessage(updateMessage) + + err = m.createIncomingContactRequestNotification(contact, state, receivedMessage, true) if err != nil { return err } @@ -2125,7 +2123,7 @@ func (m *Messenger) handleChatMessage(state *ReceivedMessageState, forceSeen boo state.AllContacts.Store(chatContact.ID, chatContact) if sendNotification { - err = m.createIncomingContactRequestEventAndNotification(chatContact, state, receivedMessage, true) + err = m.createIncomingContactRequestNotification(chatContact, state, receivedMessage, true) if err != nil { return err } @@ -2168,7 +2166,6 @@ func (m *Messenger) handleChatMessage(state *ReceivedMessageState, forceSeen boo return err } } - // Set in the modified maps chat state.Response.AddChat(chat) // TODO(samyoul) remove storing of an updated reference pointer? diff --git a/protocol/protobuf/chat_message.pb.go b/protocol/protobuf/chat_message.pb.go index b55565ee9..62693d689 100644 --- a/protocol/protobuf/chat_message.pb.go +++ b/protocol/protobuf/chat_message.pb.go @@ -68,8 +68,13 @@ const ( ChatMessage_DISCORD_MESSAGE ChatMessage_ContentType = 12 ChatMessage_IDENTITY_VERIFICATION ChatMessage_ContentType = 13 // Only local - ChatMessage_SYSTEM_MESSAGE_PINNED_MESSAGE ChatMessage_ContentType = 14 - ChatMessage_SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE ChatMessage_ContentType = 15 + ChatMessage_SYSTEM_MESSAGE_PINNED_MESSAGE ChatMessage_ContentType = 14 + // Only local + ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_SENT ChatMessage_ContentType = 15 + // Only local + ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED ChatMessage_ContentType = 16 + // Only local + ChatMessage_SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED ChatMessage_ContentType = 17 ) var ChatMessage_ContentType_name = map[int32]string{ @@ -88,7 +93,9 @@ var ChatMessage_ContentType_name = map[int32]string{ 12: "DISCORD_MESSAGE", 13: "IDENTITY_VERIFICATION", 14: "SYSTEM_MESSAGE_PINNED_MESSAGE", - 15: "SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE", + 15: "SYSTEM_MESSAGE_MUTUAL_EVENT_SENT", + 16: "SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED", + 17: "SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED", } var ChatMessage_ContentType_value = map[string]int32{ @@ -107,7 +114,9 @@ var ChatMessage_ContentType_value = map[string]int32{ "DISCORD_MESSAGE": 12, "IDENTITY_VERIFICATION": 13, "SYSTEM_MESSAGE_PINNED_MESSAGE": 14, - "SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE": 15, + "SYSTEM_MESSAGE_MUTUAL_EVENT_SENT": 15, + "SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED": 16, + "SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED": 17, } func (x ChatMessage_ContentType) String() string { @@ -1191,95 +1200,96 @@ func init() { } var fileDescriptor_263952f55fd35689 = []byte{ - // 1430 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0x5f, 0x73, 0xdb, 0x44, - 0x10, 0x8f, 0x1d, 0xff, 0x89, 0x56, 0xb6, 0x23, 0xae, 0x69, 0xab, 0x76, 0x9a, 0x36, 0xd5, 0x74, - 0x68, 0x18, 0x98, 0x30, 0x53, 0x0a, 0xd3, 0x19, 0x86, 0x61, 0x14, 0x5b, 0x4d, 0x44, 0x6b, 0xc7, - 0x9c, 0xe5, 0x96, 0xf0, 0xa2, 0x51, 0xa4, 0x4b, 0xac, 0x89, 0x2c, 0x19, 0xe9, 0x04, 0x98, 0x77, - 0x66, 0xf8, 0x44, 0x7c, 0x06, 0x1e, 0x78, 0xe5, 0x81, 0x2f, 0xc0, 0x0b, 0xaf, 0x7c, 0x00, 0xe6, - 0xee, 0xf4, 0xcf, 0xa6, 0x49, 0x99, 0x3e, 0xe9, 0x76, 0xb5, 0xbb, 0xb7, 0xfb, 0xdb, 0xbd, 0xdd, - 0x05, 0xe4, 0xce, 0x1c, 0x6a, 0xcf, 0x49, 0x92, 0x38, 0x17, 0xe4, 0x60, 0x11, 0x47, 0x34, 0x42, - 0x5b, 0xfc, 0x73, 0x96, 0x9e, 0xdf, 0x95, 0x49, 0x98, 0xce, 0x13, 0xc1, 0xbe, 0xdb, 0x75, 0xa3, - 0x90, 0x3a, 0x2e, 0x15, 0xa4, 0xf6, 0x0c, 0x7a, 0x13, 0xea, 0xbb, 0x97, 0x24, 0x1e, 0x0a, 0x6d, - 0x84, 0xa0, 0x31, 0x73, 0x92, 0x99, 0x5a, 0xdb, 0xab, 0x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ytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x9c, 0x56, 0xcd, 0x6e, 0xdb, 0xc6, + 0x13, 0xb7, 0xbe, 0xcd, 0xd1, 0x87, 0x99, 0x8d, 0x93, 0x30, 0x41, 0x9c, 0x28, 0xfa, 0x07, 0x88, + 0xff, 0x68, 0xe1, 0x02, 0x69, 0x5a, 0x04, 0x28, 0x8a, 0x82, 0x96, 0x18, 0x9b, 0x4d, 0xf4, 0xd1, + 0x15, 0xe5, 0xd4, 0xbd, 0x10, 0x34, 0xb9, 0xb6, 0x08, 0x53, 0xa4, 0x4a, 0xae, 0xda, 0xaa, 0xf7, + 0xbe, 0x52, 0x4f, 0x7d, 0x80, 0x1e, 0x7a, 0xed, 0x21, 0x2f, 0xd0, 0x27, 0xe8, 0x03, 0x14, 0xbb, + 0xcb, 0x4f, 0xd5, 0x76, 0x8a, 0x9c, 0xb8, 0x33, 0x9c, 0x99, 0x9d, 0xf9, 0xcd, 0xec, 0xcc, 0x00, + 0xb2, 0xe7, 0x16, 0x35, 0x17, 0x24, 0x8a, 0xac, 0x0b, 0x72, 0xb0, 0x0c, 0x03, 0x1a, 0xa0, 0x6d, + 0xfe, 0x39, 0x5b, 0x9d, 0x3f, 0x68, 0x12, 0x7f, 0xb5, 0x88, 0x04, 0xfb, 0x41, 0xdb, 0x0e, 0x7c, + 0x6a, 0xd9, 0x54, 0x90, 0xbd, 0x97, 0xd0, 0x99, 0x52, 0xd7, 0xbe, 0x24, 0xe1, 0x50, 0x68, 0x23, + 0x04, 0xd5, 0xb9, 0x15, 0xcd, 0x95, 0x52, 0xb7, 0xb4, 0x2f, 0x61, 0x7e, 0x66, 0xbc, 0xa5, 0x65, + 0x5f, 0x2a, 0xe5, 0x6e, 0x69, 0xbf, 0x86, 0xf9, 0xb9, 0xf7, 0x7b, 0x09, 0x5a, 0xfa, 0xc2, 0xba, + 0x20, 0x89, 0xa2, 0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00, 0x00, } diff --git a/protocol/protobuf/chat_message.proto b/protocol/protobuf/chat_message.proto index 77737640e..8d71c72ce 100644 --- a/protocol/protobuf/chat_message.proto +++ b/protocol/protobuf/chat_message.proto @@ -180,6 +180,11 @@ message ChatMessage { IDENTITY_VERIFICATION = 13; // Only local SYSTEM_MESSAGE_PINNED_MESSAGE = 14; - SYSTEM_MESSAGE_MUTUAL_STATE_UPDATE = 15; + // Only local + SYSTEM_MESSAGE_MUTUAL_EVENT_SENT = 15; + // Only local + SYSTEM_MESSAGE_MUTUAL_EVENT_ACCEPTED = 16; + // Only local + SYSTEM_MESSAGE_MUTUAL_EVENT_REMOVED = 17; } }