Add: (ement-room-set-topic)

This commit is contained in:
Adam Porter 2021-08-03 04:31:57 -05:00
parent 8fdbc4f1b3
commit 56027d8804
2 changed files with 17 additions and 0 deletions

View file

@ -98,6 +98,7 @@ If you want to install it manually, it's simple enough, but you should know what
- ~ement-leave-room~ to leave a room.
- ~ement-room-edit-message~ to edit a message at point.
- ~ement-room-send-image~ to send an image message.
- ~ement-room-set-topic~ to set a room's topic.
4. Use these special buffers to see events from multiple rooms (you can also reply to messages from these buffers!):
- See all new events that mention you in the =*Ement Mentions*= buffer.
- See all new events in rooms that have open buffers in the =*Ement Notifications*= buffer.

View file

@ -396,6 +396,22 @@ sends a not-typing notification."
;;;; Commands
(defun ement-room-set-topic (session room topic)
"Set ROOM's TOPIC on SESSION.
Interactively, set the current buffer's ROOM's TOPIC."
(interactive (list ement-session ement-room
(read-string (format "New topic (%s): "
(ement-room-display-name ement-room))
nil nil (ement-room-topic ement-room) 'inherit-input-method)))
(pcase-let* (((cl-struct ement-session server token) session)
((cl-struct ement-room (id room-id) display-name) room)
(endpoint (format "rooms/%s/state/m.room.topic" (url-hexify-string room-id)))
(data (ement-alist "topic" topic)))
(ement-api server token endpoint
(lambda (_data)
(message "Topic set (%s): %s" display-name topic))
:method 'put :data (json-encode data))))
(declare-function ement-upload "ement" t t)
(defun ement-room-send-image (file body room session)
"Send image FILE to ROOM on SESSION, using message BODY."