From aa635a3a389b184e54fc26270bc6037632ad596c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Wed, 5 Apr 2023 21:56:06 +0200 Subject: start on reporting to admins --- lisp/mastodon-tl.el | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 794b198..aa016cf 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1665,6 +1665,10 @@ webapp" (reblog (alist-get 'reblog json))) (if reblog (alist-get 'id reblog) id))) +(defun mastodon-tl--toot-or-base (json) + "Return the base toot or just the toot from toot JSON." + (or (alist-get 'reblog json) json)) + ;;; THREADS @@ -2093,6 +2097,67 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (tags (mastodon-tl--map-alist 'name followed-tags-json))) (mastodon-tl--show-tag-timeline prefix tags))) +(defun mastodon-tl--instance-rules () + "Return the rules of the user's instance." + (let ((url (mastodon-http--api "instance/rules"))) + (mastodon-http--get-json url nil :silent))) + +(defun mastodon-tl--report-to-mods () + "" + (interactive) + (when (y-or-n-p (format "report author of toot at point?")) + (let* ((url (mastodon-http--api "reports")) + (toot (mastodon-tl--toot-or-base + (mastodon-tl--property 'toot-json))) + (account (alist-get 'account toot)) + (handle (alist-get 'acct account)) + (account-id (mastodon-profile--account-field account 'id)) + (comment (read-string "Add comment [optional]: ")) + (toot-id (when (y-or-n-p "Also report status at point?") + (mastodon-tl--toot-id toot))) ; base toot if poss + (forward-p (when (y-or-n-p "Forward to remote admin?") "true")) + (rules (when (y-or-n-p "Cite a rule broken? ") + (mastodon-tl--read-rules-ids))) + (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other"))) + (params `(("account_id" . ,account-id) + ,(when comment + `("comment" . ,comment)) + ,(when toot-id + `("status_ids[]" . ,toot-id)) + ,(when forward-p + `("forward" . ,forward-p)) + ,(when cat + `("category" . ,cat))))) + (when rules + (let ((alist + (mastodon-http--build-array-params-alist "rule_ids[]" rules))) + (mapc (lambda (x) + (push x params)) + alist))) + ;; FIXME: the above approach adds nils to your params. + (setq params (delete nil params)) + (message "%s" (prin1-to-string params)) + (let ((response ;; (mastodon-http--post-async url params))) + ;; (mastodon-http--triage response + ;; (lambda (response) + ;; (message "User %s reported!" handle))) + ;; ))) + )))))) + +(defun mastodon-tl--read-rules-ids () + "Prompt for a list of instance rules and return a list of selected ids." + (let* ((rules (mastodon-tl--instance-rules)) + (alist (mapcar (lambda (x) + (cons (alist-get 'text x) + (alist-get 'id x))) + rules)) + (crm-separator (string-replace "," "|" crm-default-separator)) + (choices (completing-read-multiple + "rules [TAB for options, | to separate]: " + alist nil :match))) + (mapcar (lambda (x) + (alist-get x alist nil nil 'equal)) + choices))) ;;; UPDATING, etc. -- cgit v1.2.3 From 597d3a1f6e62df80f67fcb378342d2e2fdfeb96a Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 15 Apr 2023 20:38:04 +0200 Subject: docstring + actual request for report-to-mods --- lisp/mastodon-tl.el | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index aa016cf..3ebcec1 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2103,7 +2103,8 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (mastodon-http--get-json url nil :silent))) (defun mastodon-tl--report-to-mods () - "" + "Report the author of the toot at point to your instance moderators. +Optionally report the toot at point, optionally add a comment, optionally cite rules that have been broken, optionally forward the report to the remove admin, optionally report the account for spam." (interactive) (when (y-or-n-p (format "report author of toot at point?")) (let* ((url (mastodon-http--api "reports")) @@ -2136,13 +2137,11 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." alist))) ;; FIXME: the above approach adds nils to your params. (setq params (delete nil params)) - (message "%s" (prin1-to-string params)) - (let ((response ;; (mastodon-http--post-async url params))) - ;; (mastodon-http--triage response - ;; (lambda (response) - ;; (message "User %s reported!" handle))) - ;; ))) - )))))) + ;; (message "%s" (prin1-to-string params)) + (let ((response (mastodon-http--post-async url params))) + (mastodon-http--triage response + (lambda (response) + (message "User %s reported!" handle))))))) (defun mastodon-tl--read-rules-ids () "Prompt for a list of instance rules and return a list of selected ids." -- cgit v1.2.3 From d8149443fafae6131a52443a0c5e333bf114aab2 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 10:06:03 +0200 Subject: refactor and basic test for report to mods --- lisp/mastodon-tl.el | 79 ++++++++++++++++-------------- test/mastodon-tl-tests.el | 122 +++++++++++++++++++++++++++++----------------- 2 files changed, 120 insertions(+), 81 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 3ebcec1..0355a27 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2102,46 +2102,53 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (let ((url (mastodon-http--api "instance/rules"))) (mastodon-http--get-json url nil :silent))) +(defun mastodon-tl--report-params () + "Query user and return report params alist." + (let* ((url (mastodon-http--api "reports")) + (toot (mastodon-tl--toot-or-base + (mastodon-tl--property 'toot-json :no-move))) + (account (alist-get 'account toot)) + (handle (alist-get 'acct account)) + (account-id (mastodon-profile--account-field account 'id)) + (comment (read-string "Add comment [optional]: ")) + (toot-id (when (y-or-n-p "Also report status at point? ") + (mastodon-tl--toot-id toot))) ; base toot if poss + (forward-p (when (y-or-n-p "Forward to remote admin? ") "true")) + (rules (when (y-or-n-p "Cite a rule broken? ") + (mastodon-tl--read-rules-ids))) + (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other"))) + (params `(("account_id" . ,account-id) + ,(when comment + `("comment" . ,comment)) + ,(when toot-id + `("status_ids[]" . ,toot-id)) + ,(when forward-p + `("forward" . ,forward-p)) + ,(when cat + `("category" . ,cat))))) + (when rules + (let ((alist + (mastodon-http--build-array-params-alist "rule_ids[]" rules))) + (mapc (lambda (x) + (push x params)) + alist))) + ;; FIXME: the above approach adds nils to your params. + (setq params (delete nil params)) + params)) + (defun mastodon-tl--report-to-mods () "Report the author of the toot at point to your instance moderators. -Optionally report the toot at point, optionally add a comment, optionally cite rules that have been broken, optionally forward the report to the remove admin, optionally report the account for spam." +Optionally report the toot at point, add a comment, cite rules +that have been broken, forward the report to the remove admin, +report the account for spam." (interactive) - (when (y-or-n-p (format "report author of toot at point?")) + (when (y-or-n-p "Report author of toot at point?") (let* ((url (mastodon-http--api "reports")) - (toot (mastodon-tl--toot-or-base - (mastodon-tl--property 'toot-json))) - (account (alist-get 'account toot)) - (handle (alist-get 'acct account)) - (account-id (mastodon-profile--account-field account 'id)) - (comment (read-string "Add comment [optional]: ")) - (toot-id (when (y-or-n-p "Also report status at point?") - (mastodon-tl--toot-id toot))) ; base toot if poss - (forward-p (when (y-or-n-p "Forward to remote admin?") "true")) - (rules (when (y-or-n-p "Cite a rule broken? ") - (mastodon-tl--read-rules-ids))) - (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other"))) - (params `(("account_id" . ,account-id) - ,(when comment - `("comment" . ,comment)) - ,(when toot-id - `("status_ids[]" . ,toot-id)) - ,(when forward-p - `("forward" . ,forward-p)) - ,(when cat - `("category" . ,cat))))) - (when rules - (let ((alist - (mastodon-http--build-array-params-alist "rule_ids[]" rules))) - (mapc (lambda (x) - (push x params)) - alist))) - ;; FIXME: the above approach adds nils to your params. - (setq params (delete nil params)) - ;; (message "%s" (prin1-to-string params)) - (let ((response (mastodon-http--post-async url params))) - (mastodon-http--triage response - (lambda (response) - (message "User %s reported!" handle))))))) + (params (mastodon-tl--report-params)) + (response (mastodon-http--post-async url params))) + (mastodon-http--triage response + (lambda (response) + (message "User %s reported!" handle)))))) (defun mastodon-tl--read-rules-ids () "Prompt for a list of instance rules and return a list of selected ids." diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index a3ac330..f1b4735 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -1073,53 +1073,85 @@ correct value for following, as well as notifications enabled or disabled." (let ((response-buffer-true (current-buffer))) (insert mastodon-tl--follow-notify-true-response) (with-mock - (mock (mastodon-http--post url-follow-only nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-follow-only - user-name - user-handle - "follow") - "User some-user (@some-user@instance.url) followed!")) - (mock (mastodon-http--post url-mute nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-mute - user-name - user-handle - "mute") - "User some-user (@some-user@instance.url) muted!")) - (mock (mastodon-http--post url-block nil) - => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-block - user-name - user-handle - "block") - "User some-user (@some-user@instance.url) blocked!"))) + (mock (mastodon-http--post url-follow-only nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-follow-only + user-name + user-handle + "follow") + "User some-user (@some-user@instance.url) followed!")) + (mock (mastodon-http--post url-mute nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-mute + user-name + user-handle + "mute") + "User some-user (@some-user@instance.url) muted!")) + (mock (mastodon-http--post url-block nil) + => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-block + user-name + user-handle + "block") + "User some-user (@some-user@instance.url) blocked!"))) (with-mock - (mock (mastodon-http--post url-true nil) => response-buffer-true) - (should - (equal - (mastodon-tl--do-user-action-function url-true - user-name - user-handle - "follow" - "true") - "Receiving notifications for user some-user (@some-user@instance.url)!"))))) + (mock (mastodon-http--post url-true nil) => response-buffer-true) + (should + (equal + (mastodon-tl--do-user-action-function url-true + user-name + user-handle + "follow" + "true") + "Receiving notifications for user some-user (@some-user@instance.url)!"))))) (with-temp-buffer (let ((response-buffer-false (current-buffer))) (insert mastodon-tl--follow-notify-false-response) (with-mock - (mock (mastodon-http--post url-false nil) => response-buffer-false) - (should - (equal - (mastodon-tl--do-user-action-function url-false - user-name - user-handle - "follow" - "false") - "Not receiving notifications for user some-user (@some-user@instance.url)!"))))))) + (mock (mastodon-http--post url-false nil) => response-buffer-false) + (should + (equal + (mastodon-tl--do-user-action-function url-false + user-name + user-handle + "follow" + "false") + "Not receiving notifications for user some-user (@some-user@instance.url)!"))))))) + +(ert-deftest mastodon-tl--report-to-mods-params-alist () + "" + (with-temp-buffer + (let ((toot mastodon-tl-test-base-toot)) + (with-mock + (mock (mastodon-http--api "reports") => "https://instance.url/api/v1/reports") + (mock (mastodon-tl--toot-or-base + (mastodon-tl--property 'toot-json :no-move)) + => mastodon-tl-test-base-toot) + (mock (read-string "Add comment [optional]: ") => "Dummy complaint") + + (stub y-or-n-p => nil) ; no to all + (should (equal (mastodon-tl--report-params) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("category" . "other")))) + (with-mock + (stub y-or-n-p => t) ; yes to all + (mock (mastodon-tl--read-rules-ids) => '(1 2 3)) + ;; (mock (y-or-n-p "Also report status at point? ") => t) + ;; (mock (y-or-n-p "Forward to remote admin? ") => nil) + ;; (mock (y-or-n-p "Cite a rule broken? ") => nil) + ;; (mock (y-or-n-p "Spam? ") => nil) + (should (equal (mastodon-tl--report-params) + '(("rule_ids[]" . 3) + ("rule_ids[]" . 2) + ("rule_ids[]" . 1) + ("account_id" . 42) + ("comment" . "Dummy complaint") + ("status_ids[]" . 61208) + ("forward" . "true"))))))))) -- cgit v1.2.3 From 96fc842db36d138b3d6cbd8d109c61fb6aa2cf6f Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 11:11:13 +0200 Subject: refactor tl--report-build-params and a hack test for it --- lisp/mastodon-tl.el | 28 ++++++++++++++++++---------- test/mastodon-tl-tests.el | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 10 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 0355a27..91cc989 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2116,16 +2116,24 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (forward-p (when (y-or-n-p "Forward to remote admin? ") "true")) (rules (when (y-or-n-p "Cite a rule broken? ") (mastodon-tl--read-rules-ids))) - (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other"))) - (params `(("account_id" . ,account-id) - ,(when comment - `("comment" . ,comment)) - ,(when toot-id - `("status_ids[]" . ,toot-id)) - ,(when forward-p - `("forward" . ,forward-p)) - ,(when cat - `("category" . ,cat))))) + (cat (unless rules (if (y-or-n-p "Spam? ") "spam" "other")))) + (mastodon-tl--report-build-params account-id comment toot-id + forward-p cat rules))) + +(defun mastodon-tl--report-build-params + (account-id comment toot-id forward-p cat &optional rules) + "Build the parameters alist based on user responses. +ACCOUNT-ID, COMMENT, TOOD-ID, FORWARD-P, CAT, and RULES are all from +`mastodon-tl--report-params', which see." + (let ((params `(("account_id" . ,account-id) + ,(when comment + `("comment" . ,comment)) + ,(when toot-id + `("status_ids[]" . ,toot-id)) + ,(when forward-p + `("forward" . ,forward-p)) + ,(when cat + `("category" . ,cat))))) (when rules (let ((alist (mastodon-http--build-array-params-alist "rule_ids[]" rules))) diff --git a/test/mastodon-tl-tests.el b/test/mastodon-tl-tests.el index f1b4735..5dd6a04 100644 --- a/test/mastodon-tl-tests.el +++ b/test/mastodon-tl-tests.el @@ -1155,3 +1155,45 @@ correct value for following, as well as notifications enabled or disabled." ("comment" . "Dummy complaint") ("status_ids[]" . 61208) ("forward" . "true"))))))))) + +(ert-deftest mastodon-tl--report-build-params () + "" + (should (equal + (mastodon-tl--report-build-params 42 "Dummy complaint" + 61208 "true" nil '(1 2 3)) + '(("rule_ids[]" . 3) + ("rule_ids[]" . 2) + ("rule_ids[]" . 1) + ("account_id" . 42) + ("comment" . "Dummy complaint") + ("status_ids[]" . 61208) + ("forward" . "true")))) + (should (equal + (mastodon-tl--report-build-params 42 "Dummy complaint" + nil "true" nil nil) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("forward" . "true")))) + (should (equal + (mastodon-tl--report-build-params 42 "Dummy complaint" + 61208 "true" "spam" nil) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("status_ids[]" . 61208) + ("forward" . "true") + ("category" . "spam")))) + (should (equal + (mastodon-tl--report-build-params 42 "Dummy complaint" + 61208 "true" "other" nil) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("status_ids[]" . 61208) + ("forward" . "true") + ("category" . "other")))) + (should (equal + (mastodon-tl--report-build-params 42 "Dummy complaint" + 61208 nil "spam" nil) + '(("account_id" . 42) + ("comment" . "Dummy complaint") + ("status_ids[]" . 61208) + ("category" . "spam"))))) -- cgit v1.2.3 From 1a3efb03ba10692c897f7f20426d2f926adeef9e Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 14:27:46 +0200 Subject: clean up reports based on real-world test, flycheck, etc. --- lisp/mastodon-tl.el | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 91cc989..1fa0d09 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2080,7 +2080,7 @@ If TAG is provided, unfollow it." (defun mastodon-tl--list-followed-tags (&optional prefix) "List followed tags. View timeline of tag user choses. -Prefix is sent to `mastodon-tl--get-tag-timeline', which see." +PREFIX is sent to `mastodon-tl--get-tag-timeline', which see." (interactive "p") (let* ((followed-tags-json (mastodon-tl--followed-tags)) (tags (mastodon-tl--map-alist 'name followed-tags-json)) @@ -2091,7 +2091,7 @@ Prefix is sent to `mastodon-tl--get-tag-timeline', which see." (defun mastodon-tl--followed-tags-timeline (&optional prefix) "Open a timeline of all your followed tags. -Prefix is sent to `mastodon-tl--show-tag-timeline', which see." +PREFIX is sent to `mastodon-tl--show-tag-timeline', which see." (interactive "p") (let* ((followed-tags-json (mastodon-tl--followed-tags)) (tags (mastodon-tl--map-alist 'name followed-tags-json))) @@ -2102,14 +2102,10 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (let ((url (mastodon-http--api "instance/rules"))) (mastodon-http--get-json url nil :silent))) -(defun mastodon-tl--report-params () - "Query user and return report params alist." - (let* ((url (mastodon-http--api "reports")) - (toot (mastodon-tl--toot-or-base - (mastodon-tl--property 'toot-json :no-move))) - (account (alist-get 'account toot)) - (handle (alist-get 'acct account)) - (account-id (mastodon-profile--account-field account 'id)) +(defun mastodon-tl--report-params (account toot) + "Query user and return report params alist. +ACCOUNT and TOOT are the data to use." + (let* ((account-id (mastodon-profile--account-field account 'id)) (comment (read-string "Add comment [optional]: ")) (toot-id (when (y-or-n-p "Also report status at point? ") (mastodon-tl--toot-id toot))) ; base toot if poss @@ -2123,7 +2119,7 @@ Prefix is sent to `mastodon-tl--show-tag-timeline', which see." (defun mastodon-tl--report-build-params (account-id comment toot-id forward-p cat &optional rules) "Build the parameters alist based on user responses. -ACCOUNT-ID, COMMENT, TOOD-ID, FORWARD-P, CAT, and RULES are all from +ACCOUNT-ID, COMMENT, TOOT-ID, FORWARD-P, CAT, and RULES are all from `mastodon-tl--report-params', which see." (let ((params `(("account_id" . ,account-id) ,(when comment @@ -2152,12 +2148,19 @@ report the account for spam." (interactive) (when (y-or-n-p "Report author of toot at point?") (let* ((url (mastodon-http--api "reports")) - (params (mastodon-tl--report-params)) - (response (mastodon-http--post-async url params))) + (toot (mastodon-tl--toot-or-base + (mastodon-tl--property 'toot-json :no-move))) + (account (alist-get 'account toot)) + (handle (alist-get 'acct account)) + (params (mastodon-tl--report-params account toot)) + (response (mastodon-http--post url params))) + ;; (setq masto-report-response response) (mastodon-http--triage response - (lambda (response) + (lambda () (message "User %s reported!" handle)))))) +(defvar crm-separator) + (defun mastodon-tl--read-rules-ids () "Prompt for a list of instance rules and return a list of selected ids." (let* ((rules (mastodon-tl--instance-rules)) @@ -2165,7 +2168,7 @@ report the account for spam." (cons (alist-get 'text x) (alist-get 'id x))) rules)) - (crm-separator (string-replace "," "|" crm-default-separator)) + (crm-separator (replace-regexp-in-string "," "|" crm-separator)) (choices (completing-read-multiple "rules [TAB for options, | to separate]: " alist nil :match))) -- cgit v1.2.3 From 20085e6740d59232f0f22b62df6812b557ff921c Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 20:31:26 +0200 Subject: report to mods binding --- lisp/mastodon.el | 2 ++ 1 file changed, 2 insertions(+) (limited to 'lisp') diff --git a/lisp/mastodon.el b/lisp/mastodon.el index 81a0092..9ec1d76 100644 --- a/lisp/mastodon.el +++ b/lisp/mastodon.el @@ -83,6 +83,7 @@ (autoload 'mastodon-tl--unblock-user "mastodon-tl") (autoload 'mastodon-tl--unfollow-user "mastodon-tl") (autoload 'mastodon-tl--unmute-user "mastodon-tl") +(autoload 'mastodon-tl--report-to-mods "mastodon-tl") (autoload 'mastodon-tl--update "mastodon-tl") (autoload 'mastodon-toot--edit-toot-at-point "mastodon-toot") (when (require 'lingva nil :no-error) @@ -200,6 +201,7 @@ Use. e.g. \"%c\" for your locale's date and time format." (define-key map (kbd "C-S-B") #'mastodon-tl--unblock-user) (define-key map (kbd "M") #'mastodon-tl--mute-user) (define-key map (kbd "C-S-M") #'mastodon-tl--unmute-user) + (define-key map (kbd "Z") #'mastodon-tl--report-to-mods) ;; own profile (define-key map (kbd "O") #'mastodon-profile--my-profile) (define-key map (kbd "U") #'mastodon-profile--update-user-profile-note) -- cgit v1.2.3 From 1e671d8258c7d56b1ea07fc083c587b439b97b20 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 20:33:39 +0200 Subject: wrap report to mods in do-if-toot --- lisp/mastodon-tl.el | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 1fa0d09..7b26ecd 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2146,18 +2146,19 @@ Optionally report the toot at point, add a comment, cite rules that have been broken, forward the report to the remove admin, report the account for spam." (interactive) - (when (y-or-n-p "Report author of toot at point?") - (let* ((url (mastodon-http--api "reports")) - (toot (mastodon-tl--toot-or-base - (mastodon-tl--property 'toot-json :no-move))) - (account (alist-get 'account toot)) - (handle (alist-get 'acct account)) - (params (mastodon-tl--report-params account toot)) - (response (mastodon-http--post url params))) - ;; (setq masto-report-response response) - (mastodon-http--triage response - (lambda () - (message "User %s reported!" handle)))))) + (mastodon-tl--do-if-toot + (when (y-or-n-p "Report author of toot at point?") + (let* ((url (mastodon-http--api "reports")) + (toot (mastodon-tl--toot-or-base + (mastodon-tl--property 'toot-json :no-move))) + (account (alist-get 'account toot)) + (handle (alist-get 'acct account)) + (params (mastodon-tl--report-params account toot)) + (response (mastodon-http--post url params))) + ;; (setq masto-report-response response) + (mastodon-http--triage response + (lambda () + (message "User %s reported!" handle))))))) (defvar crm-separator) -- cgit v1.2.3 From 1715bb3f5ba468fc9d06c5835cdc9bba03de06d6 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Fri, 21 Apr 2023 21:47:42 +0200 Subject: allow zeroes in handle/tag regexes! --- lisp/mastodon-toot.el | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lisp') diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index c2c391d..4c0a274 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -217,7 +217,7 @@ send.") (concat ;; preceding bracket, space or bol [boundary doesn't work with @] "\\([(\n\t ]\\|^\\)" - "\\(?2:@[1-9a-zA-Z._-]+" ; a handle + "\\(?2:@[0-9a-zA-Z._-]+" ; a handle "\\(@[^ \n\t]*\\)?\\)" ; with poss domain, * = allow only @ "\\b")) @@ -225,7 +225,7 @@ send.") (concat ;; preceding bracket, space or bol [boundary doesn't work with #] "\\([(\n\t ]\\|^\\)" - "\\(?2:#[1-9a-zA-Z_]+\\)" ; tag + "\\(?2:#[0-9a-zA-Z_]+\\)" ; tag "\\b")) ; boundary (defvar mastodon-toot-mode-map -- cgit v1.2.3