aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-12-17 12:58:33 +0100
committermousebot <mousebot@riseup.net>2021-12-17 12:58:33 +0100
commit5288ffc54c50d41cddcd432a258ada3f7f882a93 (patch)
tree4ef4495b248755ce06003c42509cc2a4fb0036bb
parentf2af3a64967c403145c9b32aefd08ea8932a4770 (diff)
fix media attachments test before posting
if --media-attachments is non-nil, make sure we have non-nil media-args, and that we have same num of -ids to attach as attachments uploaded.
-rw-r--r--lisp/mastodon-toot.el33
1 files changed, 18 insertions, 15 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 9a88bd5..8953ee6 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -463,24 +463,27 @@ If media items have been attached and uploaded with
(symbol-name t)))
("spoiler_text" . ,spoiler)))
(args-media (when mastodon-toot--media-attachments
- (if (= (length mastodon-toot--media-attachments)
- (length mastodon-toot--media-attachment-ids))
- ;; (mastodon-toot--upload-attached-media)
- ;; moved upload to mastodon-toot--attach-media
(mapcar (lambda (id)
(cons "media_ids[]" id))
- mastodon-toot--media-attachment-ids)
- (message "Looks like something went wrong with your uploads. Maybe you want to try again."))))
+ mastodon-toot--media-attachment-ids)))
(args (append args-media args-no-media)))
- (if (> (length toot) (string-to-number mastodon-toot--max-toot-chars))
- (message "Looks like your toot is longer than that maximum allowed length.")
- (if empty-toot-p
- (message "Empty toot. Cowardly refusing to post this.")
- (let ((response (mastodon-http--post endpoint args nil)))
- (mastodon-http--triage response
- (lambda ()
- (mastodon-toot--kill)
- (message "Toot toot!"))))))))
+ (cond ((and mastodon-toot--media-attachments
+ ;; make sure we have media args
+ ;; and the same num of ids as attachments
+ (or (not args-media)
+ (not (= (length mastodon-toot--media-attachments)
+ (length mastodon-toot--media-attachment-ids)))))
+ (message "Something is wrong with your uploads. Wait for them to complete or try again."))
+ ((> (length toot) (string-to-number mastodon-toot--max-toot-chars))
+ (message "Looks like your toot is longer than that maximum allowed length."))
+ (empty-toot-p
+ (message "Empty toot. Cowardly refusing to post this."))
+ (t
+ (let ((response (mastodon-http--post endpoint args nil)))
+ (mastodon-http--triage response
+ (lambda ()
+ (mastodon-toot--kill)
+ (message "Toot toot!"))))))))
(defun mastodon-toot--process-local (acct)
"Add domain to local ACCT and replace the curent user name with \"\".