fix(mute): Fix time calculation and skip empty response sending (#3557)

This commit is contained in:
Boris Melnik 2023-06-01 17:17:42 +03:00 committed by GitHub
parent 7adfbb5467
commit af1327f95d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 2 deletions

View File

@ -1371,6 +1371,7 @@ func (m *Messenger) watchUnmutedChats() {
m.allChats.Range(func(chatID string, c *Chat) bool { m.allChats.Range(func(chatID string, c *Chat) bool {
chatMuteTill, _ := time.Parse(time.RFC3339, c.MuteTill.Format(time.RFC3339)) chatMuteTill, _ := time.Parse(time.RFC3339, c.MuteTill.Format(time.RFC3339))
currTime, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339)) currTime, _ := time.Parse(time.RFC3339, time.Now().Format(time.RFC3339))
if currTime.After(chatMuteTill) && !chatMuteTill.Equal(time.Time{}) && c.Muted { if currTime.After(chatMuteTill) && !chatMuteTill.Equal(time.Time{}) && c.Muted {
err := m.persistence.UnmuteChat(c.ID) err := m.persistence.UnmuteChat(c.ID)
if err != nil { if err != nil {
@ -1383,7 +1384,9 @@ func (m *Messenger) watchUnmutedChats() {
} }
return true return true
}) })
if !response.IsEmpty() {
signal.SendNewMessages(response) signal.SendNewMessages(response)
}
case <-m.quit: case <-m.quit:
return return
} }
@ -4933,7 +4936,7 @@ func (m *Messenger) MuteChat(request *requests.MuteChat) (time.Time, error) {
return time.Time{}, err return time.Time{}, err
} }
muteTillTimeRemoveMs, err := time.Parse("2006-01-02T15:04:05Z", MuteTill.Format("2006-01-02T15:04:05Z")) muteTillTimeRemoveMs, err := time.Parse(time.RFC3339, MuteTill.Format(time.RFC3339))
if err != nil { if err != nil {
return time.Time{}, err return time.Time{}, err