From 099006c9c31752dd53d0e6ea03281d1fa5246b83 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Wed, 22 Mar 2023 23:32:37 +0200 Subject: [PATCH] Don't read NotifySpecified in push rules --- matrix/matrix.go | 5 ++--- ui/view-main.go | 7 ++----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/matrix/matrix.go b/matrix/matrix.go index 737b497..3a9affe 100644 --- a/matrix/matrix.go +++ b/matrix/matrix.go @@ -687,10 +687,9 @@ func (c *Container) HandleMessage(source mautrix.EventSource, mxEvent *event.Eve if !room.Loaded() { pushRules := c.PushRules().GetActions(room, evt.Event).Should() - shouldNotify := pushRules.Notify || !pushRules.NotifySpecified - if !shouldNotify { + if !pushRules.Notify { room.LastReceivedMessage = time.Unix(evt.Timestamp/1000, evt.Timestamp%1000*1000) - room.AddUnread(evt.ID, shouldNotify, pushRules.Highlight) + room.AddUnread(evt.ID, pushRules.Notify, pushRules.Highlight) mainView.Bump(room) return } diff --git a/ui/view-main.go b/ui/view-main.go index 6086fc4..ed92e3a 100644 --- a/ui/view-main.go +++ b/ui/view-main.go @@ -411,17 +411,14 @@ func (view *MainView) NotifyMessage(room *rooms.Room, message ifc.Message, shoul recentlyFocused := time.Now().Add(-30 * time.Second).Before(view.lastFocusTime) isFocused := time.Now().Add(-5 * time.Second).Before(view.lastFocusTime) - // Whether or not the push rules say this message should be notified about. - shouldNotify := should.Notify || !should.NotifySpecified - if !isCurrent || !isFocused { // The message is not in the current room, show new message status in room list. - room.AddUnread(message.ID(), shouldNotify, should.Highlight) + room.AddUnread(message.ID(), should.Notify, should.Highlight) } else { view.matrix.MarkRead(room.ID, message.ID()) } - if shouldNotify && !recentlyFocused && !view.config.Preferences.DisableNotifications { + if should.Notify && !recentlyFocused && !view.config.Preferences.DisableNotifications { // Push rules say notify and the terminal is not focused, send desktop notification. shouldPlaySound := should.PlaySound && should.SoundName == "default" &&