From 6715c9b0e03a50e08a2ecc2dd9395fda0dded196 Mon Sep 17 00:00:00 2001 From: Yuchen Pei Date: Sun, 24 Nov 2024 19:54:47 +1100 Subject: 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. --- lisp/mastodon-toot.el | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'lisp/mastodon-toot.el') 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 -- cgit v1.2.3