diff options
| -rw-r--r-- | lisp/mastodon-tl.el | 12 | ||||
| -rw-r--r-- | lisp/mastodon-toot.el | 26 | 
2 files changed, 38 insertions, 0 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 51abb6e..0fcb3a3 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -3393,6 +3393,18 @@ NO-BYLINE means just insert toot body, used for announcements."    (unless (mastodon-tl--profile-buffer-p)      (mastodon-tl--goto-first-item))) +(defun mastodon-tl--remote-suspended-p (domain) +  (ignore-errors +    (alist-get 'suspended +               (mastodon-http--get-json +                (format "https://%s/api/v1/accounts/lookup" +                        domain ) +                `(("acct" . ,(format "%s@%s" +                                     mastodon-active-user +                                     (url-host +                                      (url-generic-parse-url mastodon-instance-url))))) +                t)))) +  ;;; BOOKMARKS  (require 'bookmark) 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  | 
