From 1b8b53b1186288cd67c8020af23bf9841dfaa84e Mon Sep 17 00:00:00 2001 From: BalogunofAfrica <45393944+BalogunofAfrica@users.noreply.github.com> Date: Mon, 11 Dec 2023 13:29:56 +0100 Subject: [PATCH] fix: add option to preserve history on chat delete (#4324) --- protocol/messenger_chats.go | 4 +++- protocol/requests/deactivate_chat.go | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/protocol/messenger_chats.go b/protocol/messenger_chats.go index beb0a554f..f1bf681f6 100644 --- a/protocol/messenger_chats.go +++ b/protocol/messenger_chats.go @@ -383,7 +383,9 @@ func (m *Messenger) DeactivateChat(request *requests.DeactivateChat) (*Messenger return nil, err } - return m.deactivateChat(request.ID, 0, true, true) + doClearHistory := !request.PreserveHistory + + 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 8b48df589..27c1eec93 100644 --- a/protocol/requests/deactivate_chat.go +++ b/protocol/requests/deactivate_chat.go @@ -7,7 +7,8 @@ import ( var ErrDeactivateChatInvalidID = errors.New("deactivate-chat: invalid id") type DeactivateChat struct { - ID string `json:"id"` + ID string `json:"id"` + PreserveHistory bool `json:"preserveHistory"` } func (j *DeactivateChat) Validate() error {