diff options
Diffstat (limited to 'lisp/mastodon-tl.el')
-rw-r--r-- | lisp/mastodon-tl.el | 33 |
1 files changed, 18 insertions, 15 deletions
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))) |