aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authormarty hiatt <martianhiatus@riseup.net>2024-08-03 10:07:44 +0200
committermarty hiatt <martianhiatus@riseup.net>2024-08-03 10:07:44 +0200
commitfe7ae6ecb2445b84563debd5bb0ad9d37ee291b0 (patch)
treef69967d94af187f138c114c5ac4e4a43752800fe /lisp/mastodon-toot.el
parent72d4d0e77faa891bd249cefca1375c82b0e6dc62 (diff)
max attachments: move fallback into our get max fun
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el17
1 files 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?"