diff options
author | mousebot <mousebot@riseup.net> | 2021-06-05 12:43:19 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-06-05 12:43:19 +0200 |
commit | a32a239d7e64d46df8e76c712a2335cecf8776e9 (patch) | |
tree | 8835e5713b81b50b96ef99f71636e67b06ab4f69 /lisp/mastodon-http.el | |
parent | 21bbab0885097ce7e47cbb88f9214c1f507adf87 (diff) |
implement updating user profile note
uses a tiny minor mode 'profile-update', with bindings.
U is a general binding for it.
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 25 |
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) |