From fe7ae6ecb2445b84563debd5bb0ad9d37ee291b0 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 3 Aug 2024 10:07:44 +0200 Subject: max attachments: move fallback into our get max fun --- lisp/mastodon-toot.el | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 3728bc8..0b28538 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -1247,12 +1247,17 @@ Return its two letter ISO 639 1 code." (mastodon-toot--update-status-fields)) (defun mastodon-toot--get-instance-max-attachments () - "Return the maximum attachments from `mastodon-active-user's instance." + "Return the maximum attachments from `mastodon-active-user's instance. +If that fails, return 4 as a fallback" ;; FIXME: this likely various for other server types: - (let ((config (alist-get 'statuses - (alist-get 'configuration - (mastodon-views--get-own-instance))))) - (alist-get 'max_media_attachments config))) + ;; pleroma doesn't advertise this on "api/v1/instance" (checked + ;; fe.disroot.org) + (or + (let ((config (alist-get 'statuses + (alist-get 'configuration + (mastodon-views--get-own-instance))))) + (alist-get 'max_media_attachments config)) + 4)) ; mastodon default as fallback (defun mastodon-toot--attach-media (file description) "Prompt for an attachment FILE with DESCRIPTION. @@ -1262,7 +1267,7 @@ File is actually attached to the toot upon posting." (interactive "fFilename: \nsDescription: ") (let ((max-attachments (mastodon-toot--get-instance-max-attachments))) (when (>= (length mastodon-toot--media-attachments) - (or max-attachments 4)) + max-attachments) ;; warn + pop the oldest one: (when (y-or-n-p (format "Maximum attachments (%s) reached: remove first one?" -- cgit v1.2.3