From 3c1d3150e1be8fe23948a0adb0f5341227532fb5 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 16 Mar 2024 11:27:41 +0100 Subject: PUT attachment alt-text in media upload callback. (pleroma) --- lisp/mastodon-http.el | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) (limited to 'lisp/mastodon-http.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index aef8975..49c94a4 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -338,18 +338,27 @@ The upload is asynchronous. On succeeding, item uploaded, and `mastodon-toot--update-status-fields' is run." (let* ((file (file-name-nondirectory filename)) (request-backend 'curl) + (desc `(("description" . ,caption))) (cb (cl-function (lambda (&key data &allow-other-keys) (when data - (push (alist-get 'id data) - mastodon-toot--media-attachment-ids) ; add ID to list - (message (alist-get 'id data)) - (message "Uploading %s... (done)" file) - (mastodon-toot--update-status-fields)))))) + (let* ((id (alist-get 'id data))) + ;; update ids: + (push id mastodon-toot--media-attachment-ids) + ;; pleroma, PUT the description: + ;; this is how the mangane akkoma web client does it + ;; and it seems easier than the other options! + (when (and caption + (not (equal caption (alist-get 'description data)))) + (let ((url (mastodon-http--api (format "media/%s" id)))) + ;; (message "PUTting image description") + (mastodon-http--put url desc))) + (message "Uploading %s... (done)" file) + (mastodon-toot--update-status-fields))))))) (request url :type "POST" - :params `(("description" . ,caption)) + :params desc :files `(("file" . (,file :file ,filename :mime-type "multipart/form-data"))) :parser 'json-read -- cgit v1.2.3