From b7dea3af5a08582ebbf3e6dff5dfccf1a70ce22d Mon Sep 17 00:00:00 2001 From: balogunofafrica Date: Wed, 15 Nov 2023 13:26:59 +0100 Subject: [PATCH] fix: add option to preserve history on chat delete --- protocol/messenger_chats.go | 4 +++- protocol/requests/deactivate_chat.go | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/protocol/messenger_chats.go b/protocol/messenger_chats.go index 6d24ac0a0ea..3de60a45fa2 100644 --- a/protocol/messenger_chats.go +++ b/protocol/messenger_chats.go @@ -382,8 +382,10 @@ func (m *Messenger) DeactivateChat(request *requests.DeactivateChat) (*Messenger if err := request.Validate(); err != nil { return nil, err } + + doClearHistory := !request.PreserveHistory - return m.deactivateChat(request.ID, 0, true, true) + return m.deactivateChat(request.ID, 0, true, doClearHistory) } func (m *Messenger) deactivateChat(chatID string, deactivationClock uint64, shouldBeSynced bool, doClearHistory bool) (*MessengerResponse, error) { diff --git a/protocol/requests/deactivate_chat.go b/protocol/requests/deactivate_chat.go index 8b48df589b7..63b12ea1959 100644 --- a/protocol/requests/deactivate_chat.go +++ b/protocol/requests/deactivate_chat.go @@ -8,6 +8,7 @@ var ErrDeactivateChatInvalidID = errors.New("deactivate-chat: invalid id") type DeactivateChat struct { ID string `json:"id"` + PreserveHistory bool `json:"preserveHistory"` } func (j *DeactivateChat) Validate() error {