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:
parent
cc0bb8540e
commit
b395144704
|
@ -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)
|
||||||
|
|
Loading…
Reference in New Issue