aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authorYuchen Pei <id@ypei.org>2024-11-24 19:54:47 +1100
committerYuchen Pei <id@ypei.org>2024-12-22 21:47:35 +1100
commit6715c9b0e03a50e08a2ecc2dd9395fda0dded196 (patch)
tree05622bd9f4e2d248a0255707699671140bb45fcc /lisp/mastodon-toot.el
parent4077de24da84e57a313382e92242daf9be1b5b5f (diff)
Display a warning when composing a reply mentioning users from instances that have suspended you
These users would not be able to see your reply through their instances.
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el26
1 files changed, 26 insertions, 0 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 4ba5e5d..bc34bcd 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -1784,6 +1784,29 @@ REPLY-REGION is a string to be injected into the buffer."
(setq mastodon-toot--visibility reply-visibility))
(mastodon-toot--set-cw reply-cw))))
+(defun mastodon-toot--warn-remote-suspension (reply-to-user)
+ (let* ((domains
+ (delete-dups
+ (mapcar
+ (lambda (user) (caddr (string-split user "@")))
+ (string-split reply-to-user " "))))
+ (suspended-by
+ (seq-filter
+ #'mastodon-tl--remote-suspended-p
+ domains)))
+ (cond ((length= domains (length suspended-by))
+ (display-warning
+ 'mastodon
+ "All domains of user mentions in this reply draft have suspended you"
+ :warning))
+ (suspended-by
+ (display-warning
+ 'mastodon
+ (format
+ "Some domains of user mentions in this reply draft have suspended you: %s"
+ (string-join suspended-by " "))
+ :warning)))))
+
(defun mastodon-toot--update-status-fields (&rest _args)
"Update the status fields in the header based on the current state."
(ignore-errors ;; called from after-change-functions so let's not leak errors
@@ -2025,6 +2048,8 @@ EDIT means we are editing an existing toot, not composing a new one."
(mastodon-toot--display-docs-and-status-fields reply-text)
(mastodon-toot--fill-reply-in-compose))
(mastodon-toot--display-docs-and-status-fields))
+ (setq reply-to-user (string-join
+ (delete-dups (string-split reply-to-user " ")) " "))
;; `reply-to-user' (alone) is also used by `mastodon-tl--dm-user', so
;; perhaps we should not always call --setup-as-reply, or make its
;; workings conditional on reply-to-id. currently it only checks for
@@ -2032,6 +2057,7 @@ EDIT means we are editing an existing toot, not composing a new one."
(mastodon-toot--setup-as-reply reply-to-user reply-to-id reply-json
;; only initial-text if reply (not edit):
(when reply-json initial-text))
+ (mastodon-toot--warn-remote-suspension reply-to-user)
(unless mastodon-toot--max-toot-chars
;; no need to fetch from `mastodon-profile-account-settings' as
;; `mastodon-toot--max-toot-chars' is set when we set it