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

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

[elpa] externals/ement 66feed66aa 3/4: Add: (ement-create-space)


From: ELPA Syncer
Subject: [elpa] externals/ement 66feed66aa 3/4: Add: (ement-create-space)
Date: Fri, 31 Mar 2023 04:57:55 -0400 (EDT)

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

    Add: (ement-create-space)
---
 README.org   |  1 +
 ement-lib.el | 26 +++++++++++++++++++++++---
 2 files changed, 24 insertions(+), 3 deletions(-)

diff --git a/README.org b/README.org
index f7c08aa002..f8925a649e 100644
--- a/README.org
+++ b/README.org
@@ -117,6 +117,7 @@ Ement.el is intended to be installed with Emacs's package 
system, which will ens
       -  ~ement-list-rooms~ to view the list of joined rooms.
       -  ~ement-view-room~ to view a room's buffer, selected with completion.
       -  ~ement-create-room~ to create a new room.
+      -  ~ement-create-space~ to create a space.
       -  ~ement-invite-user~ to invite a user to a room.
       -  ~ement-join-room~ to join a room.
       -  ~ement-leave-room~ to leave a room.
diff --git a/ement-lib.el b/ement-lib.el
index a3ab821d32..ceaee59699 100644
--- a/ement-lib.el
+++ b/ement-lib.el
@@ -110,7 +110,7 @@ contrast colour with RGB as background and as foreground."
 ;;;;; Commands
 
 (cl-defun ement-create-room
-    (session &key name alias topic invite direct-p
+    (session &key name alias topic invite direct-p creation-content
              (then (lambda (data)
                      (message "Created new room: %s" (alist-get 'room_id 
data))))
              (visibility 'private))
@@ -118,7 +118,8 @@ contrast colour with RGB as background and as foreground."
 Then call function THEN with response data.  Optional string
 arguments are NAME, ALIAS, and TOPIC.  INVITE may be a list of
 user IDs to invite.  If DIRECT-P, set the \"is_direct\" flag in
-the request."
+the request.  CREATION-CONTENT may be an alist of extra keys to
+include with the request (see Matrix spec)."
   ;; TODO: Document other arguments.
   ;; SPEC: 10.1.1.
   (declare (indent defun))
@@ -141,10 +142,29 @@ the request."
                         (when invite
                           (push (cons "invite" invite) it))
                         (when direct-p
-                          (push (cons "is_direct" t) it)))))
+                          (push (cons "is_direct" t) it))
+                         (when creation-content
+                           (push (cons "creation_content" creation-content) 
it)))))
       (ement-api session endpoint :method 'post :data (json-encode data)
         :then then))))
 
+(cl-defun ement-create-space
+    (session &key name alias topic
+             (then (lambda (data)
+                     (message "Created new space: %s" (alist-get 'room_id 
data))))
+             (visibility 'private))
+  "Create new space on SESSION.
+Then call function THEN with response data.  Optional string
+arguments are NAME, ALIAS, and TOPIC."
+  (declare (indent defun))
+  (interactive (list (ement-complete-session)
+                    :name (read-string "New space name: ")
+                    :alias (read-string "New space alias (e.g. \"foo\" for 
\"#foo:matrix.org\"): ")
+                    :topic (read-string "New space topic: ")
+                    :visibility (completing-read "New space visibility: " 
'(private public))))
+  (ement-create-room session :name name :alias alias :topic topic :visibility 
visibility
+    :creation-content (ement-alist "type" "m.space") :then then))
+
 (defun ement-room-leave (room session &optional force-p)
   "Leave ROOM on SESSION.
 If FORCE-P, leave without prompting.  ROOM may be an `ement-room'



reply via email to

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