From b8d0c9b967fbc1e38e4012ad357a7f29c621acc1 Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Oct 2023 11:36:58 +0200 Subject: triage: call cb on response. do-user-action-fun: check response data this means the triage callback always needs to handle 1 arg. --- lisp/mastodon-tl.el | 60 ++++++++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 26 deletions(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 673856b..088e3db 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -1229,7 +1229,7 @@ displayed when the duration is smaller than a minute)." (arg `(("choices[]" . ,option-as-arg))) (response (mastodon-http--post url arg))) (mastodon-http--triage response - (lambda () + (lambda (_) (message "You voted for option %s: %s!" (car option) (cdr option))))))) @@ -1852,7 +1852,7 @@ If UNMUTE, unmute it." (when (y-or-n-p (format "%s this thread? " (capitalize mute-str))) (let ((response (mastodon-http--post url))) (mastodon-http--triage response - (lambda () + (lambda (_) (if unmute (message "Thread unmuted!") (message "Thread muted!"))))))))))) @@ -2086,27 +2086,35 @@ ARGS is an alist of any parameters to send with the request." (let ((response (mastodon-http--post url args))) (mastodon-http--triage response - (lambda () - (cond ((string-equal notify "true") - (message "Receiving notifications for user %s (@%s)!" - name user-handle)) - ((string-equal notify "false") - (message "Not receiving notifications for user %s (@%s)!" - name user-handle)) - ((string-equal reblogs "true") - (message "Receiving boosts by user %s (@%s)!" - name user-handle)) - ((string-equal reblogs "false") - (message "Not receiving boosts by user %s (@%s)!" - name user-handle)) - ((or (string-equal action "mute") - (string-equal action "unmute")) - (message "User %s (@%s) %sd!" name user-handle action)) - ((assoc "languages[]" args #'equal) - (message "User %s filtered by language(s): %s" name - (mapconcat #'cdr args " "))) - ((eq notify nil) - (message "User %s (@%s) %sed!" name user-handle action))))))) + (lambda (response) + (let ((json (with-current-buffer response + (mastodon-http--process-json)))) + ;; TODO: when > if, with failure msg + (cond ((string-equal notify "true") + (when (equal 't (alist-get 'notifying json)) + (message "Receiving notifications for user %s (@%s)!" + name user-handle))) + ((string-equal notify "false") + (when (equal :json-false (alist-get 'notifying json)) + (message "Not receiving notifications for user %s (@%s)!" + name user-handle))) + ((string-equal reblogs "true") + (when (equal 't (alist-get 'showing_reblogs json)) + (message "Receiving boosts by user %s (@%s)!" + name user-handle))) + ((string-equal reblogs "false") + (when (equal :json-false (alist-get 'showing_reblogs json)) + (message "Not receiving boosts by user %s (@%s)!" + name user-handle))) + ((or (string-equal action "mute") + (string-equal action "unmute")) + (message "User %s (@%s) %sd!" name user-handle action)) + ((assoc "languages[]" args #'equal) + (message "User %s filtered by language(s): %s" name + (mapconcat #'cdr args " "))) + ((and (eq notify nil) + (eq reblogs nil)) + (message "User %s (@%s) %sed!" name user-handle action)))))))) ;; FOLLOW TAGS @@ -2135,7 +2143,7 @@ If TAG provided, follow it." (url (mastodon-http--api (format "tags/%s/follow" tag))) (response (mastodon-http--post url))) (mastodon-http--triage response - (lambda () + (lambda (_) (message "tag #%s followed!" tag))))) (defun mastodon-tl--followed-tags () @@ -2153,7 +2161,7 @@ If TAG is provided, unfollow it." (url (mastodon-http--api (format "tags/%s/unfollow" tag))) (response (mastodon-http--post url))) (mastodon-http--triage response - (lambda () + (lambda (_) (message "tag #%s unfollowed!" tag))))) (defun mastodon-tl--list-followed-tags (&optional prefix) @@ -2249,7 +2257,7 @@ report the account for spam." (params (mastodon-tl--report-params account toot)) (response (mastodon-http--post url params))) (mastodon-http--triage response - (lambda () + (lambda (_) (message "User %s reported!" handle))))))) (defvar crm-separator) -- cgit v1.2.3 From 1bfcb22043580d6bc4252300f55135aac8c50aea Mon Sep 17 00:00:00 2001 From: marty hiatt Date: Sat, 28 Oct 2023 14:50:18 +0200 Subject: note re tags timeline limit number of tags --- lisp/mastodon-tl.el | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'lisp/mastodon-tl.el') diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el index 088e3db..135c7f5 100644 --- a/lisp/mastodon-tl.el +++ b/lisp/mastodon-tl.el @@ -2177,7 +2177,9 @@ 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. +Note that the number of tags supported is undocumented, and from +manual testing appears to be limited to a total of four tags." (interactive "p") (let* ((followed-tags-json (mastodon-tl--followed-tags)) (tags (mastodon-tl--map-alist 'name followed-tags-json))) -- cgit v1.2.3