From b395144704f29c9e1f4fd11714d1031a10160ad1 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Fri, 4 Jun 2021 09:18:32 +0200 Subject: [PATCH] Upsert one to one chat on mute Before, status-react would make sure a chat existed before muting, now the logic is all in the endpoint. --- VERSION | 2 +- protocol/messenger.go | 18 +++++++++++++++++- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index 03eec4e5d..5b29a6679 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.79.10 +0.79.11 diff --git a/protocol/messenger.go b/protocol/messenger.go index 988fb71f7..86da7a048 100644 --- a/protocol/messenger.go +++ b/protocol/messenger.go @@ -3114,7 +3114,23 @@ func (m *Messenger) MarkAllRead(chatID string) error { func (m *Messenger) MuteChat(chatID string) error { chat, ok := m.allChats.Load(chatID) if !ok { - return errors.New("chat not found") + // Only one to one chan be muted when it's not in the database + publicKey, err := common.HexToPubkey(chatID) + if err != nil { + return err + } + + // Create a one to one chat and set active to false + chat = CreateOneToOneChat(chatID, publicKey, m.getTimesource()) + chat.Active = false + err = m.initChatSyncFields(chat) + if err != nil { + return err + } + err = m.saveChat(chat) + if err != nil { + return err + } } err := m.persistence.MuteChat(chatID)