branch: externals/ement commit 5a7c0782069af8f37e4e2ba3cd8c025ee562dded Author: Arto Jantunen <vi...@iki.fi> Commit: Adam Porter <a...@alphapapa.net>
Add a function for downloading the file pointed to by an event --- ement-room.el | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ement-room.el b/ement-room.el index 491e5bc77d..18c2032c98 100644 --- a/ement-room.el +++ b/ement-room.el @@ -5935,6 +5935,21 @@ For use in `completion-at-point-functions'." (apply callback 'status cbargs)))))) (eww-browse-url mxc)))) +;;;; Downloading media/files + +(defun ement-room-download-event-file (event) + (pcase-let* (((cl-struct ement-event + (content (map ('filename event-filename) + ('url mxc-url)))) + event)) + (let* ((session ement-session) + (dir (if (stringp eww-download-directory) + eww-download-directory + (funcall eww-download-directory))) + (filename (expand-file-name (file-name-nondirectory event-filename) dir))) + (access-file dir "Download failed") + (ement--media-request mxc-url session :as (list 'file filename))))) + ;;;; Footer (provide 'ement-room)