aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-profile.el
diff options
context:
space:
mode:
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r--lisp/mastodon-profile.el81
1 files changed, 42 insertions, 39 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el
index 0c1ec91..82eb4db 100644
--- a/lisp/mastodon-profile.el
+++ b/lisp/mastodon-profile.el
@@ -46,6 +46,7 @@
(autoload 'mastodon-tl--byline-author "mastodon-tl.el")
(autoload 'mastodon-tl--goto-next-toot "mastodon-tl.el")
(autoload 'mastodon-tl--property "mastodon-tl.el")
+(autoload 'mastodon-tl--find-property-range "mastodon-tl.el")
(autoload 'mastodon-tl--render-text "mastodon-tl.el")
(autoload 'mastodon-tl--set-face "mastodon-tl.el")
(autoload 'mastodon-tl--timeline "mastodon-tl.el")
@@ -70,8 +71,8 @@
(let ((map (make-sparse-keymap)))
(define-key map (kbd "O") #'mastodon-profile--open-followers)
(define-key map (kbd "o") #'mastodon-profile--open-following)
- (define-key map (kbd "C-c a") #'mastodon-profile--follow-request-accept)
- (define-key map (kbd "C-c r") #'mastodon-profile--follow-request-reject)
+ (define-key map (kbd "a") #'mastodon-profile--follow-request-accept)
+ (define-key map (kbd "j") #'mastodon-profile--follow-request-reject)
map)
"Keymap for `mastodon-profile-mode'.")
@@ -110,13 +111,12 @@ extra keybindings."
(mastodon-tl--property 'toot-json))
(defun mastodon-profile--make-author-buffer (account)
- "Take a ACCOUNT and inserts a user account into a new buffer."
+ "Take a ACCOUNT and insert a user account into a new buffer."
(mastodon-profile--make-profile-buffer-for
account "statuses" #'mastodon-tl--timeline))
(defun mastodon-profile--open-following ()
- "Open a profile buffer for the current profile showing the accounts
-that current profile follows."
+ "Open a profile buffer showing the accounts that current profile follows."
(interactive)
(if mastodon-profile--account
(mastodon-profile--make-profile-buffer-for
@@ -126,8 +126,7 @@ that current profile follows."
(error "Not in a mastodon profile")))
(defun mastodon-profile--open-followers ()
- "Open a profile buffer for the current profile showing the accounts
-following the current profile."
+ "Open a profile buffer showing the accounts following the current profile."
(interactive)
(if mastodon-profile--account
(mastodon-profile--make-profile-buffer-for
@@ -155,42 +154,46 @@ following the current profile."
(defun mastodon-profile--follow-request-accept ()
"Accept the follow request of user at point."
(interactive)
- (let* ((acct-json (mastodon-profile--toot-json))
- (id (cdr (assoc 'id acct-json)))
- (handle (cdr (assoc 'acct acct-json)))
- (name (cdr (assoc 'username acct-json))))
- (if id
- (let ((response
- (mastodon-http--post
- (concat
- (mastodon-http--api "follow_requests")
- (format "/%s/authorize" id))
- nil nil)))
- (mastodon-http--triage response
- (lambda ()
- (message "Follow request of %s (@%s) accepted!"
- name handle))))
- (message "No account result at point?"))))
+ (if (mastodon-tl--find-property-range 'toot-json (point))
+ (let* ((acct-json (mastodon-profile--toot-json))
+ (id (cdr (assoc 'id acct-json)))
+ (handle (cdr (assoc 'acct acct-json)))
+ (name (cdr (assoc 'username acct-json))))
+ (if id
+ (let ((response
+ (mastodon-http--post
+ (concat
+ (mastodon-http--api "follow_requests")
+ (format "/%s/authorize" id))
+ nil nil)))
+ (mastodon-http--triage response
+ (lambda ()
+ (message "Follow request of %s (@%s) accepted!"
+ name handle))))
+ (message "No account result at point?")))
+ (message "No follow request at point?")))
(defun mastodon-profile--follow-request-reject ()
"Reject the follow request of user at point."
(interactive)
- (let* ((acct-json (mastodon-profile--toot-json))
- (id (cdr (assoc 'id acct-json)))
- (handle (cdr (assoc 'acct acct-json)))
- (name (cdr (assoc 'username acct-json))))
- (if id
- (let ((response
- (mastodon-http--post
- (concat
- (mastodon-http--api "follow_requests")
- (format "/%s/reject" id))
- nil nil)))
- (mastodon-http--triage response
- (lambda ()
- (message "Follow request of %s (@%s) rejected!"
- name handle))))
- (message "No account result at point?"))))
+ (if (mastodon-tl--find-property-range 'toot-json (point))
+ (let* ((acct-json (mastodon-profile--toot-json))
+ (id (cdr (assoc 'id acct-json)))
+ (handle (cdr (assoc 'acct acct-json)))
+ (name (cdr (assoc 'username acct-json))))
+ (if id
+ (let ((response
+ (mastodon-http--post
+ (concat
+ (mastodon-http--api "follow_requests")
+ (format "/%s/reject" id))
+ nil nil)))
+ (mastodon-http--triage response
+ (lambda ()
+ (message "Follow request of %s (@%s) rejected!"
+ name handle))))
+ (message "No account result at point?")))
+ (message "No follow request at point?")))
(defun mastodon-profile--update-user-profile-note ()
"Fetch user's profile note and display for editing."