aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/mastodon-http.el26
-rw-r--r--lisp/mastodon-toot.el6
2 files changed, 14 insertions, 18 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index 31ea483..cd89cc5 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -249,11 +249,11 @@ Authorization header is included by default unless UNAUTHENTICED-P is non-nil."
(defun mastodon-http--post-media-attachment (url filename caption)
"Make POST request to upload FILENAME with CAPTION to the server's media URL.
-The upload is asynchronous. On succeeding, `mastodon-toot--media-attachment-ids' is set to the id(s) of the item uploaded, `mastodon-toot--media-attachments' is set to t, and `mastodon-toot--update-status-fields' is run."
+The upload is asynchronous. On succeeding, `mastodon-toot--media-attachment-ids' is set to the id(s) of the item uploaded, and `mastodon-toot--update-status-fields' is run."
(let* ((file (file-name-nondirectory filename))
- (request-backend 'curl)
- (response
- (request
+ (request-backend 'curl))
+ ;; (response
+ (request
url
:type "POST"
:params `(("description" . ,caption))
@@ -278,15 +278,15 @@ The upload is asynchronous. On succeeding, `mastodon-toot--media-attachment-ids'
(mastodon-toot--update-status-fields)))))
:error (cl-function
(lambda (&key error-thrown &allow-other-keys)
- (message "Got error: %s" error-thrown))))))
- (pcase (request-response-status-code response)
- (200
- (request-response-data response))
- (401
- (error "Unauthorized: The access token is invalid"))
- (422
- (error "Unprocessable entity: file or file type is unsupported or invalid"))
- (_ (error "Shit went south")))))
+ (message "%s" (car (last error-thrown)))
+ (message "%s" (type-of (car (last error-thrown))))
+ (cond ((= (car (last error-thrown)) 401)
+ (message "Got error: %s Unauthorized: The access token is invalid" error-thrown))
+ ((= (car (last error-thrown)) 422)
+ (message "Got error: %s Unprocessable entity: file or file type is unsupported or invalid" error-thrown))
+ (t
+ (message "Got error: %s Shit went south"
+ error-thrown))))))))
(provide 'mastodon-http)
;;; mastodon-http.el ends here
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 95f562c..0c3c784 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -78,10 +78,6 @@ Must be one of \"public\", \"unlisted\", \"private\" (for followers-only), or \"
Valid values are \"direct\", \"private\" (followers-only), \"unlisted\", and \"public\".")
(make-variable-buffer-local 'mastodon-toot--visibility)
-(defvar mastodon-toot--media-attachments nil
- "A flag indicating if the toot being composed has media attachments.")
-(make-variable-buffer-local 'mastodon-toot--media-attachments)
-
(defvar mastodon-toot--media-attachment-ids nil
"A list of any media attachment ids of the toot being composed.")
(make-variable-buffer-local 'mastodon-toot--media-attachment-ids)
@@ -316,7 +312,7 @@ If media items have been uploaded with `mastodon-toot--add-media-attachment', at
(symbol-name t)))
("spoiler_text" . ,spoiler)))
(args-media
- (when mastodon-toot--media-attachments
+ (when mastodon-toot--media-attachment-ids
(mapcar
(lambda (id)
(cons "media_ids[]" id))