emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/ement 198e198f15 1/4: Change: (ement-put-account-data)


From: ELPA Syncer
Subject: [elpa] externals/ement 198e198f15 1/4: Change: (ement-put-account-data) Add :room
Date: Sun, 5 Mar 2023 23:57:51 -0500 (EST)

branch: externals/ement
commit 198e198f15516ce45371a95c270b1799be037d57
Author: Adam Porter <adam@alphapapa.net>
Commit: Adam Porter <adam@alphapapa.net>

    Change: (ement-put-account-data) Add :room
---
 README.org   |  4 ++++
 ement-lib.el | 12 ++++++++----
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/README.org b/README.org
index 1f0678afd3..467615bea3 100644
--- a/README.org
+++ b/README.org
@@ -294,6 +294,10 @@ Note that, while ~matrix-client~ remains usable, and 
probably will for some time
 + Improve display of room tombstones (displayed at top and bottom of buffer, 
and new room ID is linked to join).
 + Use descriptive prompts in ~ement-leave-room~ and ~ement-forget-room~ 
commands.
 
+*Internal*
+
++ Function ~ement-put-account-data~ accepts ~:room~ argument to put on a 
room's account data.
+
 ** 0.6
 
 *Additions*
diff --git a/ement-lib.el b/ement-lib.el
index 8d4870d7d1..bb21fdf83f 100644
--- a/ement-lib.el
+++ b/ement-lib.el
@@ -723,12 +723,14 @@ unseen user IDs to be input as well."
          selected-user))))
 
 (cl-defun ement-put-account-data
-    (session type data &key
+    (session type data &key room
              (then (lambda (received-data)
                      ;; Handle echoed-back account data event (the spec does 
not explain this,
                      ;; but see 
<https://github.com/matrix-org/matrix-react-sdk/blob/675b4271e9c6e33be354a93fcd7807253bd27fcd/src/settings/handlers/AccountSettingsHandler.ts#L150>).
                      ;; FIXME: Make session account-data a map instead of a 
list of events.
-                     (push received-data (ement-session-account-data session))
+                     (if room
+                         (push received-data (ement-room-account-data room))
+                       (push received-data (ement-session-account-data 
session)))
 
                      ;; NOTE: Commenting out this ement-debug form because a 
bug in Emacs
                      ;; causes this long string to be interpreted as the 
function's
@@ -738,10 +740,12 @@ unseen user IDs to be input as well."
                      ;;              (ement-user-id (ement-session-user 
session)) (json-encode data) received-data)
                      )))
   "Put account data of TYPE with DATA on SESSION.
-Also handle the echoed-back event."
+If ROOM, put it on that room's account data.  Also handle the
+echoed-back event."
   (declare (indent defun))
   (pcase-let* (((cl-struct ement-session (user (cl-struct ement-user (id 
user-id)))) session)
-               (endpoint (format "user/%s/account_data/%s" (url-hexify-string 
user-id) type)))
+               (room-part (if room (format "/rooms/%s" (ement-room-id room)) 
""))
+               (endpoint (format "user/%s%s/account_data/%s" 
(url-hexify-string user-id) room-part type)))
     (ement-api session endpoint :method 'put :data (json-encode data)
       :then then)))
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]