diff options
author | marty hiatt <martianhiatus@riseup.net> | 2023-11-06 21:17:53 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus@riseup.net> | 2023-11-06 21:33:04 +0100 |
commit | f1af40e2c00e9a7db67e4e1c153a77cd61d8c562 (patch) | |
tree | fd4b64834d0409c5136ded62233222a6df0022de /lisp/mastodon-http.el | |
parent | 406d87cc7ad075a2c1cc2044e151eba7d8110191 (diff) |
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!
Diffstat (limited to 'lisp/mastodon-http.el')
-rw-r--r-- | lisp/mastodon-http.el | 10 |
1 files changed, 7 insertions, 3 deletions
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) |