summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Okay <cbeok@protonmail.com>2020-04-25 08:22:59 -0500
committerColin Okay <cbeok@protonmail.com>2020-04-25 08:22:59 -0500
commit884432d544de2925c918f0014b61950e4c8677d0 (patch)
tree060cc7cc12af3f97c50282d1d72264ebf3727453
parent504dd83798f522d0dd0a1c9a6045c3f1e7448616 (diff)
added user-search
-rw-r--r--granolin.lisp20
1 files changed, 20 insertions, 0 deletions
diff --git a/granolin.lisp b/granolin.lisp
index c0bd998..a5846a9 100644
--- a/granolin.lisp
+++ b/granolin.lisp
@@ -216,6 +216,7 @@
(defparameter +create-room-path+ "/_matrix/client/r0/createRoom")
(defparameter +update-account-data-path+ "/_matrix/client/r0/user/~a/account_data/~a")
(defparameter +upload-path+ "/_matrix/media/r0/upload?filename=~a")
+(defparameter +user-directory-path+ "/_matrix/client/r0/user_directory/search")
;;; Utility functions and macros for making HTTP requests to the MATRIX API
@@ -568,6 +569,25 @@
*response-status*
(flexi-streams:octets-to-string *response-body*)))))
+(defun user-search (client query &key (limit 10))
+ "QUERY is a string. Returns a plist of the form:
+
+(:|results|
+ ((:|avatar_url| NIL :|display_name| \"bob\" :|user_id|
+ \"@bob:my.matrix.host\")
+ (:|avatar_url| NIL :|display_name| \"jill\" :|user_id|
+ \"@jill:my.matrix.host\")
+ ;; ... more ...
+ )
+ :|limited| NIL)
+ "
+ (let ((body (list :|search_term| query :|limit| limit)))
+ (send (client +user-directory-path+ body
+ :method :post
+ :content-type "application/json"
+ :wrap make-basic-json)
+ (basic-json-data *response-object*) )))
+
(defun update-account-data (client m-type data)
"Serializes the PLIST DATA as JSON and PUTs it in account_data at the given M-TYPE.