aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-http.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r--lisp/mastodon-http.el25
1 files changed, 24 insertions, 1 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index e85429f..678e628 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -137,7 +137,7 @@ Pass response buffer to CALLBACK function."
(with-temp-buffer
(url-retrieve-synchronously url))))
-;; http functions for search:
+;; search functions:
(defun mastodon-http--process-json-search ()
"Process JSON returned by a search query to the server."
(goto-char (point-min))
@@ -168,6 +168,29 @@ Pass response buffer to CALLBACK function."
(url-retrieve-synchronously url)
(url-retrieve-synchronously url nil nil mastodon-http--timeout))))
+;; profile update functions
+
+(defun mastodon-http--patch-json (url)
+ "Make synchronous PATCH request to URL. Return JSON response."
+ (with-current-buffer (mastodon-http--patch url)
+ (mastodon-http--process-json)))
+
+;; hard coded just for bio note for now:
+(defun mastodon-http--patch (base-url &optional note)
+ "Make synchronous PATCH request to URL.
+
+Pass response buffer to CALLBACK function."
+ (let ((url-request-method "PATCH")
+ (url (if note
+ (concat base-url "?note=" (url-hexify-string note))
+ base-url))
+ (url-request-extra-headers
+ `(("Authorization" . ,(concat "Bearer "
+ (mastodon-auth--access-token))))))
+ (if (< (cdr (func-arity 'url-retrieve-synchronously)) 4)
+ (url-retrieve-synchronously url)
+ (url-retrieve-synchronously url nil nil mastodon-http--timeout))))
+
;; Asynchronous functions
(defun mastodon-http--get-async (url &optional callback &rest cbargs)