diff options
-rw-r--r-- | README.org | 3 | ||||
-rw-r--r-- | lisp/mastodon-profile.el | 42 |
2 files changed, 40 insertions, 5 deletions
@@ -266,6 +266,9 @@ work without first loading =mastodon.el=: - =mastodon-profile--view-account-private-note=: View a private note on a user’s account. +- =mastodon-profile--show-familiar-followers=: Show a list of “familiar followers” for a given account. Familiar followers are accounts that you follow, and that follow the account. + + - =mastodon-tl--follow-tag=: Follow a tag (works like following a user) - =mastodon-tl--unfollow-tag=: Unfollow a tag - =mastodon-tl--list-followed-tags=: View a list of tags you're following. diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index e6f5853..3661615 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -938,15 +938,19 @@ NOTE-OLD is the text of any existing note." (let ((inhibit-read-only t)) (princ note)))) +(defun mastodon-profile--grab-profile-json () + "Return the profile-json property if we are in a profile buffer." + (when (mastodon-tl--profile-buffer-p) + (save-excursion + (goto-char (point-min)) + (or (mastodon-tl--property 'profile-json) + (error "No profile data found"))))) + (defun mastodon-profile--add-or-view-private-note (action-fun &optional message view) "Add or view a private note for an account. ACTION-FUN does the adding or viewing, MESSAGE is a prompt for `mastodon-tl--interactive-user-handles-get', VIEW is a flag." - (let* ((profile-json (when (mastodon-tl--profile-buffer-p) - (save-excursion - (goto-char (point-min)) - (or (mastodon-tl--property 'profile-json) - (error "No profile data found"))))) + (let* ((profile-json (mastodon-profile--grab-profile-json)) (handle (if (mastodon-tl--profile-buffer-p) (alist-get 'acct profile-json) (mastodon-tl--interactive-user-handles-get message))) @@ -962,5 +966,33 @@ ACTION-FUN does the adding or viewing, MESSAGE is a prompt for (funcall action-fun note)) (funcall action-fun id handle note)))) +(defun mastodon-profile--show-familiar-followers () + "Show a list of familiar followers. +Familiar followers are accounts that you follow, and that follow +the given account." + (interactive) + (let* ((profile-json (mastodon-profile--grab-profile-json)) + (handle + (if (mastodon-tl--profile-buffer-p) + (alist-get 'acct profile-json) + (mastodon-tl--interactive-user-handles-get "show familiar followers of"))) + (account (if (mastodon-tl--profile-buffer-p) + profile-json + (mastodon-profile--search-account-by-handle handle))) + (id (alist-get 'id account))) + (mastodon-profile--get-familiar-followers id))) + +(defun mastodon-profile--get-familiar-followers (id) + "Return JSON data of familiar followers for account ID." + ;; the server can handle multiple IDs, but for now we just handle one. + (let* ((params `(("id" . ,id))) + (url (mastodon-http--api "accounts/familiar_followers")) + (json (mastodon-http--get-json url params)) + (accounts (alist-get 'accounts (car json))) ; first id result + (handles (mastodon-tl--map-get-accts accounts)) + (choice (completing-read "Show profile of user: " + handles))) + (mastodon-profile--show-user choice))) + (provide 'mastodon-profile) ;;; mastodon-profile.el ends here |