aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lisp/mastodon-http.el4
-rw-r--r--lisp/mastodon-profile.el45
-rw-r--r--lisp/mastodon.el3
3 files changed, 41 insertions, 11 deletions
diff --git a/lisp/mastodon-http.el b/lisp/mastodon-http.el
index f26d808..3fe47c9 100644
--- a/lisp/mastodon-http.el
+++ b/lisp/mastodon-http.el
@@ -106,9 +106,7 @@ Pass response buffer to CALLBACK function."
(url-retrieve-synchronously url nil nil mastodon-http--timeout))))
(defun mastodon-http--delete (url)
- "Make DELETE request to URL.
-
-Pass response buffer to CALLBACK function."
+ "Make DELETE request to URL."
(let ((url-request-method "DELETE")
(url-request-extra-headers
`(("Authorization" . ,(concat "Bearer "
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index bd325c1..e0e209d 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -100,6 +100,15 @@ following the current profile."
#'mastodon-profile--add-author-bylines)
(error "Not in a mastodon profile")))
+(defun mastodon-profile--relationships-get (id)
+ "Fetch info about logged in user's relationship to user with id ID."
+ (interactive)
+ (let* ((their-id id)
+ (url (mastodon-http--api (format
+ "accounts/relationships?id[]=%s"
+ their-id))))
+ (mastodon-http--get-json url)))
+
(defun mastodon-profile--make-profile-buffer-for (account endpoint-type update-function)
(let* ((id (mastodon-profile--account-field account 'id))
(url (mastodon-http--api (format "accounts/%s/%s"
@@ -113,9 +122,20 @@ following the current profile."
(buffer (concat "*mastodon-" acct "-" endpoint-type "*"))
(note (mastodon-profile--account-field account 'note))
(id (mastodon-profile--account-field account 'id))
- (fol_count (mastodon-tl--as-string (mastodon-profile--account-field account 'followers_count)))
- (folling_count (mastodon-tl--as-string (mastodon-profile--account-field account 'following_count)))
- (toots_count (mastodon-tl--as-string (mastodon-profile--account-field account 'statuses_count))))
+ (followers-count (mastodon-tl--as-string
+ (mastodon-profile--account-field
+ account 'followers_count)))
+ (following-count (mastodon-tl--as-string
+ (mastodon-profile--account-field
+ account 'following_count)))
+ (toots-count (mastodon-tl--as-string
+ (mastodon-profile--account-field
+ account 'statuses_count)))
+ (followed-by-you (cdr (assoc 'following
+ (aref (mastodon-profile--relationships-get id) 0))))
+ (follows-you (cdr (assoc 'followed_by
+ (aref (mastodon-profile--relationships-get id) 0))))
+ (followsp (or (equal follows-you 't) (equal followed-by-you 't))))
(with-output-to-temp-buffer buffer
(switch-to-buffer buffer)
(mastodon-mode)
@@ -147,11 +167,20 @@ following the current profile."
(mastodon-tl--render-text note nil)
(mastodon-tl--set-face
(concat " ------------\n"
- " TOOTS: " toots_count " | "
- "FOLLOWERS: " fol_count " | "
- "FOLLOWING: " folling_count "\n"
+ " TOOTS: " toots-count " | "
+ "FOLLOWERS: " followers-count " | "
+ "FOLLOWING: " following-count "\n"
" ------------\n\n")
'success)
+ (if followsp
+ (mastodon-tl--set-face
+ (concat (if (equal follows-you 't)
+ "FOLLOWS YOU | ")
+ (if (equal followed-by-you 't)
+ "FOLLOWED BY YOU | ")
+ "\n\n")
+ 'success)
+ "") ; if no followsp we still need str-or-char-p for insert
(mastodon-tl--set-face
(concat " ------------\n"
endpoint-name "\n"
@@ -163,7 +192,9 @@ following the current profile."
(mastodon-tl--goto-next-toot)))
(defun mastodon-profile--get-toot-author ()
- "Opens authors profile of toot under point."
+ "Open profile of author of toot under point.
+
+If toot is a boost, opens the profile of the booster."
(interactive)
(mastodon-profile--make-author-buffer
(cdr (assoc 'account (mastodon-profile--toot-json)))))
diff --git a/lisp/mastodon.el b/lisp/mastodon.el
index accbed8..6862e52 100644
--- a/lisp/mastodon.el
+++ b/lisp/mastodon.el
@@ -153,7 +153,8 @@ Use. e.g. \"%c\" for your locale's date and time format."
(defun mastodon ()
"Connect Mastodon client to `mastodon-instance-url' instance."
(interactive)
- (mastodon-tl--get-home-timeline))
+ (mastodon-tl--get-home-timeline)
+ (message "Loading Mastodon account %s on %s..." (mastodon-auth--get-account-name) mastodon-instance-url))
;;;###autoload
(defun mastodon-toot (&optional user reply-to-id)