mirror of
https://github.com/status-im/status-go.git
synced 2025-01-12 15:45:07 +00:00
Set joined=message.clock on syncing pubchat creation
This commit is contained in:
parent
91e9fb4804
commit
36b4ecabbf
@ -346,10 +346,10 @@ func (m *Messenger) DeactivateChat(request *requests.DeactivateChat) (*Messenger
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return m.deactivateChat(request.ID, true)
|
||||
return m.deactivateChat(request.ID, 0, true)
|
||||
}
|
||||
|
||||
func (m *Messenger) deactivateChat(chatID string, shouldBeSynced bool) (*MessengerResponse, error) {
|
||||
func (m *Messenger) deactivateChat(chatID string, deactivationClock uint64, shouldBeSynced bool) (*MessengerResponse, error) {
|
||||
var response MessengerResponse
|
||||
chat, ok := m.allChats.Load(chatID)
|
||||
if !ok {
|
||||
@ -375,9 +375,11 @@ func (m *Messenger) deactivateChat(chatID string, shouldBeSynced bool) (*Messeng
|
||||
}
|
||||
}
|
||||
|
||||
clock, _ := chat.NextClockAndTimestamp(m.getTimesource())
|
||||
if deactivationClock == 0 {
|
||||
deactivationClock, _ = chat.NextClockAndTimestamp(m.getTimesource())
|
||||
}
|
||||
|
||||
err = m.persistence.DeactivateChat(chat, clock)
|
||||
err = m.persistence.DeactivateChat(chat, deactivationClock)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
@ -214,7 +214,7 @@ func (m *Messenger) removeContact(ctx context.Context, response *MessengerRespon
|
||||
_, ok = m.allChats.Load(profileChatID)
|
||||
|
||||
if ok {
|
||||
chatResponse, err := m.deactivateChat(profileChatID, false)
|
||||
chatResponse, err := m.deactivateChat(profileChatID, 0, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -421,8 +421,9 @@ func (m *Messenger) HandleSyncInstallationPublicChat(state *ReceivedMessageState
|
||||
chat := existingChat
|
||||
if !ok {
|
||||
chat = CreatePublicChat(chatID, state.Timesource)
|
||||
chat.Joined = int64(message.Clock)
|
||||
} else {
|
||||
existingChat.Joined = int64(state.Timesource.GetCurrentTime())
|
||||
existingChat.Joined = int64(message.Clock)
|
||||
}
|
||||
|
||||
state.AllChats.Store(chat.ID, chat)
|
||||
@ -448,7 +449,7 @@ func (m *Messenger) HandleSyncChatRemoved(state *ReceivedMessageState, message p
|
||||
}
|
||||
}
|
||||
|
||||
response, err := m.deactivateChat(message.Id, false)
|
||||
response, err := m.deactivateChat(message.Id, message.Clock, false)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ func (s *MessengerInstallationSuite) TestSyncInstallation() {
|
||||
chat2 := CreatePublicChat(removedChatID, s.m.transport)
|
||||
err = s.m.SaveChat(chat2)
|
||||
s.Require().NoError(err)
|
||||
_, err = s.m.deactivateChat(removedChatID, true)
|
||||
_, err = s.m.deactivateChat(removedChatID, 0, true)
|
||||
s.Require().NoError(err)
|
||||
|
||||
// pair
|
||||
|
@ -121,7 +121,7 @@ func (s *MessengerSyncChatSuite) TestRemovePubChat() {
|
||||
|
||||
s.Pair()
|
||||
|
||||
_, err = s.alice1.deactivateChat(publicChatName, true)
|
||||
_, err = s.alice1.deactivateChat(publicChatName, 0, true)
|
||||
s.Require().NoError(err)
|
||||
|
||||
var allChats []*Chat
|
||||
|
Loading…
x
Reference in New Issue
Block a user