aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-http.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-10-01 22:20:45 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-10-01 22:20:45 +0200
commitdb078f72b7d176f18e24792e93319322b02795bb (patch)
treef04bcd815877ff845be449109a35bf2d8c39d228 /lisp/mastodon-http.el
parent2a3255c48f8e3538a7604d96ebadb9e21b0b9c50 (diff)
rewrite http--patch (+ json confusion)
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r--lisp/mastodon-http.el21
1 files changed, 18 insertions, 3 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index fbae8a7..546d5bd 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -298,11 +298,26 @@ Optionally specify the PARAMS to send."
(with-current-buffer (mastodon-http--patch url params)
(mastodon-http--process-json)))
-(defun mastodon-http--patch (base-url &optional params)
- "Make synchronous PATCH request to BASE-URL.
+(defun mastodon-http--patch (url &optional params json)
+ "Make synchronous PATCH request to URL.
Optionally specify the PARAMS to send."
(mastodon-http--authorized-request "PATCH"
- (let ((url (mastodon-http--concat-params-to-url base-url params)))
+ ;; NB: unlike POST, PATCHing only works if we use query params!
+ ;; so here, unless JSON arg, we use query params and do not set
+ ;; `url-request-data'. this is probably an error, i don't understand it.
+ (let* ((url-request-data
+ (when (and params json)
+ (encode-coding-string
+ (json-encode params) 'utf-8)))
+ ;; (mastodon-http--build-params-string params))))
+ (url (unless json
+ (mastodon-http--concat-params-to-url url params)))
+ (headers (when json
+ '(("Content-Type" . "application/json")
+ ("Accept" . "application/json"))))
+ (url-request-extra-headers
+ (append url-request-extra-headers headers)))
+ (message "Data: %s" url-request-data)
(mastodon-http--url-retrieve-synchronously url))))
;; Asynchronous functions