From f1af40e2c00e9a7db67e4e1c153a77cd61d8c562 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Mon, 6 Nov 2023 21:17:53 +0100 Subject: edit toots adopt attachments. FIX #506 - fetch media from url (http--read-file-as-string) - on edit, set media-attachments/-ids with the data from the toot/url - nb: users still can't edit attachments, can only remove all or maintain them as they are. but that's much better than always nuking them! --- lisp/mastodon-http.el | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lisp/mastodon-http.el') diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el index 1edc8b5..8764764 100644 --- a/lisp/mastodon-http.el +++ b/lisp/mastodon-http.el @@ -98,10 +98,14 @@ RESPONSE if unsuccessful." (mastodon-http--process-json)))) (message "Error %s: %s" status (alist-get 'error json-response))))))) -(defun mastodon-http--read-file-as-string (filename) - "Read a file FILENAME as a string. Used to generate image preview." +(defun mastodon-http--read-file-as-string (filename &optional url) + "Read a file FILENAME as a string. +Used to generate image preview. +URL means FILENAME is a URL." (with-temp-buffer - (insert-file-contents filename) + (if url + (url-insert-file-contents filename) + (insert-file-contents filename)) (string-to-unibyte (buffer-string)))) (defmacro mastodon-http--authorized-request (method body &optional unauthenticated-p) -- cgit v1.2.3