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.
This commit is contained in:
Andrea Maria Piana 2021-06-04 09:18:32 +02:00
parent cc0bb8540e
commit b395144704
2 changed files with 18 additions and 2 deletions

View File

@ -1 +1 @@
0.79.10 0.79.11

View File

@ -3114,7 +3114,23 @@ func (m *Messenger) MarkAllRead(chatID string) error {
func (m *Messenger) MuteChat(chatID string) error { func (m *Messenger) MuteChat(chatID string) error {
chat, ok := m.allChats.Load(chatID) chat, ok := m.allChats.Load(chatID)
if !ok { 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) err := m.persistence.MuteChat(chatID)