From 71f66f68064e9897cd17b6bcecba426a91405034 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Mon, 24 May 2021 10:27:56 +0200 Subject: [PATCH] Set timestamp on group chat invitation --- VERSION | 2 +- protocol/chat.go | 13 +++++++++---- protocol/message_handler.go | 3 --- protocol/messenger.go | 5 ----- 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/VERSION b/VERSION index de4de0978..256129378 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.79.2 +0.79.3 diff --git a/protocol/chat.go b/protocol/chat.go index ccc3cca93..ba0190f7d 100644 --- a/protocol/chat.go +++ b/protocol/chat.go @@ -381,11 +381,16 @@ func CreateProfileChat(pubkey string, timesource common.TimeSource) *Chat { } func CreateGroupChat(timesource common.TimeSource) Chat { + timestamp := timesource.GetCurrentTime() + synced := uint32(timestamp / 1000) + return Chat{ - Active: true, - Color: chatColors[rand.Intn(len(chatColors))], // nolint: gosec - Timestamp: int64(timesource.GetCurrentTime()), - ChatType: ChatTypePrivateGroupChat, + Active: true, + Color: chatColors[rand.Intn(len(chatColors))], // nolint: gosec + Timestamp: int64(timestamp), + SyncedTo: synced, + SyncedFrom: synced, + ChatType: ChatTypePrivateGroupChat, } } diff --git a/protocol/message_handler.go b/protocol/message_handler.go index a83ea2f64..0ea033980 100644 --- a/protocol/message_handler.go +++ b/protocol/message_handler.go @@ -128,9 +128,6 @@ func (m *MessageHandler) HandleMembershipUpdate(messageState *ReceivedMessageSta // unless is coming from us or a contact isActive := messageState.CurrentMessageState.Contact.IsAdded() || messageState.CurrentMessageState.Contact.ID == ourKey newChat.Active = isActive - timestamp := uint32(newChat.Timestamp / 1000) - newChat.SyncedTo = timestamp - newChat.SyncedFrom = timestamp chat = &newChat } else { existingGroup, err := newProtocolGroupFromChat(chat) diff --git a/protocol/messenger.go b/protocol/messenger.go index f528c4e4d..116189dfb 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -1185,11 +1185,6 @@ func (m *Messenger) CreateGroupChatWithMembers(ctx context.Context, name string, return nil, err } - timestamp := uint32(chat.Timestamp / 1000) - - chat.SyncedTo = timestamp - chat.SyncedFrom = timestamp - m.allChats.Store(chat.ID, &chat) _, err = m.dispatchMessage(ctx, common.RawMessage{