branch: externals/ement
commit eb0e0f85cf5a998a3e82084ccea2a3e978733309
Merge: dbe2212cba 89b3fc3510
Author: Adam Porter <a...@alphapapa.net>
Commit: Adam Porter <a...@alphapapa.net>

    Fix: (ement-room-notification-state) Push rules' actions order
    
    Closes #190.  Thanks to Steven Allen (@Stebalien).
---
 README.org   |  1 +
 ement-lib.el | 11 ++++++-----
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/README.org b/README.org
index 71e304e617..7cbd2314bf 100644
--- a/README.org
+++ b/README.org
@@ -309,6 +309,7 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 
 *Fixes*
 + Allow editing of already-edited events.
++ Push rules' actions may be listed in any order.  (Fixes compatibility with 
[[https://spec.matrix.org/v1.7/client-server-api/#actions][v1.7 of the spec]].  
Thanks to [[https://github.com/Stebalien][Steven Allen]].)
 + Call external browser for SSO login page.  (JavaScript is usually required, 
which EWW doesn't support, and loading the page twice seems to change state on 
the server that causes the SSO login to fail, so it's best to load the page in 
the external browser directly).
 + Clean up SSO server process after two minutes in case SSO login fails.
 + Don't stop syncing if an error is signaled while sending a notification.
diff --git a/ement-lib.el b/ement-lib.el
index 985523d1de..a0edf9db9a 100644
--- a/ement-lib.el
+++ b/ement-lib.el
@@ -41,6 +41,7 @@
 
 (require 'color)
 (require 'map)
+(require 'seq)
 (require 'xml)
 
 (require 'ement-api)
@@ -597,12 +598,12 @@ Returns one of nil (meaning default rules are used), 
`all-loud',
                                          (equal "room_id" key)
                                          (equal (ement-room-id room) 
pattern)))))
                 (mute-rule-p
-                 (rule) (and (= 1 (length (alist-get 'actions rule)))
-                             (equal "dont_notify" (elt (alist-get 'actions 
rule) 0))))
+                 (rule) (when-let ((actions (alist-get 'actions rule)))
+                          (seq-contains-p actions "dont_notify")))
                 (tweak-rule-p
-                 (type rule) (pcase-let (((map ('actions `[,action ,alist])) 
rule))
-                               (and (equal "notify" action)
-                                    (equal type (alist-get 'set_tweak 
alist))))))
+                 (type rule) (when-let ((actions (alist-get 'actions rule)))
+                               (and (seq-contains-p actions "notify")
+                                    (seq-contains-p actions `(set_tweak . 
,type) 'seq-contains-p)))))
       ;; If none of these match, nil is returned, meaning that the default 
rule is used
       ;; for the room.
       (if (override-mute-rule-for-room-p room)

Reply via email to