diff options
author | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-27 11:44:34 +0100 |
---|---|---|
committer | marty hiatt <martianhiatus [a t] riseup [d o t] net> | 2022-11-27 11:44:34 +0100 |
commit | fa82691cc42a4344015a4920ee0582a92897160b (patch) | |
tree | 5d36815d10826bedf780c21ec35dc2309203c405 | |
parent | accc0c8b451580169300d28974c62650e5e30aac (diff) |
unmute or mute a thread
-rw-r--r-- | lisp/mastodon-tl.el | 29 |
1 files changed, 24 insertions, 5 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index fe865d0..fbf1b7b 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1510,8 +1510,20 @@ ID is that of the toot to view." (defun mastodon-tl--mute-thread () - "Mute the thread displayed in the current buffer." + "Mute the thread displayed in the current buffer. +Note that you can only (un)mute threads you have posted in." (interactive) + (mastodon-tl--mute-or-unmute-thread)) + +(defun mastodon-tl--unmute-thread () + "Mute the thread displayed in the current buffer. +Note that you can only (un)mute threads you have posted in." + (interactive) + (mastodon-tl--mute-or-unmute-thread :unmute)) + +(defun mastodon-tl--mute-or-unmute-thread (&optional unmute) + "Mute a thread. +If UNMUTE, unmute it." (let ((endpoint (mastodon-tl--get-endpoint))) (if (string-suffix-p "context" endpoint) ; thread view (let* ((id @@ -1520,14 +1532,21 @@ ID is that of the toot to view." endpoint))) (match-string 2 endpoint)))) (we-posted-p (mastodon-tl--user-in-thread-p id)) - (url (mastodon-http--api (format "statuses/%s/mute" id)))) + (url (mastodon-http--api + (if unmute + (format "statuses/%s/unmute" id) + (format "statuses/%s/mute" id))))) (if (not we-posted-p) - (message "You can only mute a thread you have posted in.") - (when (y-or-n-p "Mute this thread? ") + (message "You can only (un)mute a thread you have posted in.") + (when (if unmute + (y-or-n-p "Unute this thread? ") + (y-or-n-p "Mute this thread? ")) (let ((response (mastodon-http--post url))) (mastodon-http--triage response (lambda () - (message "Thread muted!")))))))))) + (if unmute + (message "Thread unmuted!") + (message "Thread muted!"))))))))))) (defun mastodon-tl--user-in-thread-p (id) "Return non-nil if the logged-in user has posted to the current thread. |