aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-05-08 10:06:28 +0200
committermousebot <mousebot@riseup.net>2021-05-08 10:06:28 +0200
commit083b085ebce6753001c8fe6798f5f44f2c3971c1 (patch)
tree9ca4c91619f05d9802a7985329db9bce9c5791d5
parentf511b7ca340918901d1eb9d0a6e97029ad92c443 (diff)
re-write follow-user fun with completing read
-rw-r--r--lisp/mastodon-tl.el32
1 files changed, 20 insertions, 12 deletions
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index d271243..14623e6 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -798,19 +798,27 @@ webapp"
(lambda ()
(message "Toot deleted! There may be a delay before it disappears from your profile."))))))
-;; follow user at point:
-;; try to make it work only for toot user id first, then try to allow mentions/boosts
-(defun mastodon-tl--follow-user ()
- "Follow author OR BOOSTER! of toot at point synchronously."
- (interactive)
- (let* ((account
- (cdr (assoc 'account (mastodon-profile--toot-json)))) ; acc data from toot
- (user-id (mastodon-profile--account-field account 'id)) ; id from acc
+(defun mastodon-tl--follow-user (user-handle)
+ "Query user for user id from current status and follow that user."
+ (interactive
+ (list
+ (let ((user-handles (mastodon-profile--extract-users-handles
+ (mastodon-profile--toot-json))))
+ (completing-read "User handle: "
+ user-handles
+ nil ; predicate
+ 'confirm))))
+ (let* ((account (mastodon-profile--lookup-account-in-status
+ user-handle (mastodon-profile--toot-json)))
+ (user-id (mastodon-profile--account-field account 'id))
+ (name (mastodon-profile--account-field account 'display_name))
(url (mastodon-http--api (format "accounts/%s/follow" user-id))))
- (let ((response (mastodon-http--post url nil nil)))
- (mastodon-http--triage response
- (lambda ()
- (message "User ID %s followed!" user-id)))))) ; TODO: use handle
+ (if account
+ (let ((response (mastodon-http--post url nil nil)))
+ (mastodon-http--triage response
+ (lambda ()
+ (message "User %s (@%s) followed!" name user-handle))))
+ (message "Cannot find a user with handle %S" user-handle))))
(defun mastodon-tl--more ()
"Append older toots to timeline."