diff options
author | mousebot <mousebot@riseup.net> | 2021-05-30 13:34:37 +0200 |
---|---|---|
committer | mousebot <mousebot@riseup.net> | 2021-05-30 13:34:37 +0200 |
commit | 9c2ab0ac9965d5bb90984d179fb17abcb2cd8ab8 (patch) | |
tree | 2f6d7b38b5becd8cdbea3092dd04f4522b88acd7 /lisp/mastodon-profile.el | |
parent | a9ea433fdee9df9c04705ca41ad517308b6b444e (diff) |
view favourites fun, and view/accept/reject follow requests funs.
and bindings.
view-follow-requests makes mastodon-tl--init run in mastodon-profile-mode
just so that its bindings can be restricted to that minor mode.
Diffstat (limited to 'lisp/mastodon-profile.el')
-rw-r--r-- | lisp/mastodon-profile.el | 64 |
1 files changed, 62 insertions, 2 deletions
diff --git a/lisp/mastodon-profile.el b/lisp/mastodon-profile.el index f117f23..17b480d 100644 --- a/lisp/mastodon-profile.el +++ b/lisp/mastodon-profile.el @@ -69,8 +69,12 @@ extra keybindings." :lighter " Profile" ;; The key bindings :keymap '(((kbd "O") . mastodon-profile--open-followers) - ((kbd "o") . mastodon-profile--open-following)) - :group 'mastodon) + ((kbd "o") . mastodon-profile--open-following) + ((kbd "v") . mastodon-profile--view-favourites) + ((kbd "R") . mastodon-profile--view-follow-requests) + ((kbd "a") . mastodon-profile--follow-request-accept) + ((kbd "r") . mastodon-profile--follow-request-reject)) +:group 'mastodon) (defun mastodon-profile--toot-json () "Get the next toot-json." @@ -104,6 +108,62 @@ following the current profile." #'mastodon-profile--add-author-bylines) (error "Not in a mastodon profile"))) +(defun mastodon-profile--view-favourites () + "Open a new buffer displaying the user's favourites." + (interactive) + (mastodon-tl--init "favourites" + "favourites" + 'mastodon-tl--timeline)) + +(defun mastodon-profile--view-follow-requests () + "Open a new buffer displaying the user's follow requests." + (interactive) + (mastodon-profile-mode) + (mastodon-tl--init "follow-requests" + "follow_requests" + 'mastodon-profile--add-author-bylines)) + +(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?")))) + +(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?")))) + + (defun mastodon-profile--relationships-get (id) "Fetch info about logged-in user's relationship to user with id ID." (let* ((their-id id) |