aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-http.el
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-10-29 17:55:27 +0200
committermousebot <mousebot@riseup.net>2021-10-29 18:08:28 +0200
commit7e7b6c5c67af47c37d2a856dd72ccc040c967482 (patch)
tree0a60a70bdafce933b532964919cf7fdc68aef50e /lisp/mastodon-http.el
parent39a54a6aaf1a6f043bfe8769ef0c3484de917e7c (diff)
merge upload-media-attachments functionality into toot-send.
this obviates the need for the user to upload files before posting their toot. - this commit makes http--post-media-attachment synchronous, so that toot-send has to wait for it. - in toot-send: if mastodon-toot--media-attachements is non-nil, the files it contains are uploaded synchronously, and their returned ids are added to toot-media-attachment-ids, which are parsed as args for the POST request to be attached to the toot. - then we send toot as usual. - clear-all-attachments also clears mastodon-toot--media-attachment-ids just in case. - we have no more need of media-attachments-filenames, as media-attachments is now a list and not a boolean value.
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r--lisp/mastodon-http.el7
1 files changed, 4 insertions, 3 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index b5437a3..d6158eb 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -256,7 +256,9 @@ Authorization header is included by default unless UNAUTHENTICED-P is non-nil."
;; TODO: test for curl first?
(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, 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
@@ -269,14 +271,13 @@ The upload is asynchronous. On succeeding, `mastodon-toot--media-attachment-ids'
:parser 'json-read
:headers `(("Authorization" . ,(concat "Bearer "
(mastodon-auth--access-token))))
- :sync nil
+ :sync t
:success (cl-function
(lambda (&key data &allow-other-keys)
(when data
(progn
(push (cdr (assoc 'id data))
mastodon-toot--media-attachment-ids) ; add ID to list
- (push file mastodon-toot--media-attachment-filenames)
(message "%s file %s with id %S and caption '%s' uploaded!"
(capitalize (cdr (assoc 'type data)))
file