aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-http.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-02-28 21:35:22 +0100
committermarty hiatt <martianhiatus [a t] riseup [d o t] net>2023-02-28 21:35:22 +0100
commit1152970f4051c0656fde9e0ee5b142c852ee41a9 (patch)
treea4b12238aa2e980f9660432cefc40e37a28eec82 /lisp/mastodon-http.el
parent7d4d8bc059c9253b66fb694593e7c9bc8bafbc41 (diff)
parentb9368c00359bc6407048669539957a45cac47297 (diff)
Merge branch 'develop'
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r--lisp/mastodon-http.el17
1 files changed, 12 insertions, 5 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 9ef7aec..88bc9c6 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -73,7 +73,6 @@
(defun mastodon-http--url-retrieve-synchronously (url &optional silent)
"Retrieve URL asynchronously.
-
This is a thin abstraction over the system
`url-retrieve-synchronously'. Depending on which version of this
is available we will call it with or without a timeout.
@@ -84,7 +83,6 @@ SILENT means don't message."
(defun mastodon-http--triage (response success)
"Determine if RESPONSE was successful. Call SUCCESS if successful.
-
Message status and JSON error from RESPONSE if unsuccessful."
(let ((status (with-current-buffer response
(mastodon-http--status))))
@@ -136,7 +134,6 @@ Used for API form data parameters that take an array."
(defun mastodon-http--post (url &optional params headers unauthenticated-p)
"POST synchronously to URL, optionally with PARAMS and HEADERS.
-
Authorization header is included by default unless UNAUTHENTICATED-P is non-nil."
(mastodon-http--authorized-request
"POST"
@@ -207,8 +204,18 @@ Callback to `mastodon-http--get-response-async', usually
(buffer-substring-no-properties (point) (point-max))
'utf-8)))
(kill-buffer)
- (unless (or (string-empty-p json-string) (null json-string))
- `(,(json-read-from-string json-string) . ,headers)))))
+ ;; (unless (or (string-empty-p json-string) (null json-string))
+ (cond ((or (string-empty-p json-string) (null json-string))
+ nil)
+ ;; if we don't have json, maybe we have a plain string error
+ ;; message (misskey works like this for instance, but there are
+ ;; probably less dunce ways to do this):
+ ;; FIXME: friendica at least sends plain html if endpoint not found.
+ ((not (or (string-prefix-p "\n{" json-string)
+ (string-prefix-p "\n[" json-string)))
+ (error "%s" json-string))
+ (t
+ `(,(json-read-from-string json-string) . ,headers))))))
(defun mastodon-http--process-headers ()
"Return an alist of http response headers."