aboutsummaryrefslogtreecommitdiff
path: root/lisp
diff options
context:
space:
mode:
authormousebot <mousebot@riseup.net>2021-05-30 13:34:37 +0200
committermousebot <mousebot@riseup.net>2021-05-30 13:34:37 +0200
commit9c2ab0ac9965d5bb90984d179fb17abcb2cd8ab8 (patch)
tree2f6d7b38b5becd8cdbea3092dd04f4522b88acd7 /lisp
parenta9ea433fdee9df9c04705ca41ad517308b6b444e (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')
-rw-r--r--lisp/mastodon-discover.el6
-rw-r--r--lisp/mastodon-profile.el64
-rw-r--r--lisp/mastodon-tl.el2
3 files changed, 69 insertions, 3 deletions
diff --git a/lisp/mastodon-discover.el b/lisp/mastodon-discover.el
index 55623f7..1f063b3 100644
--- a/lisp/mastodon-discover.el
+++ b/lisp/mastodon-discover.el
@@ -83,7 +83,11 @@
("u" "copy URL" 'shr-maybe-probe-and-copy-url))
("Profile view"
("o" "Show following" mastodon-profile--open-following)
- ("O" "Show followers" mastodon-profile--open-followers))
+ ("O" "Show followers" mastodon-profile--open-followers)
+ ("v" "View favourites" mastodon-profile--view-favourites)
+ ("R" "View follow requests" mastodon-profile--view-follow-requests)
+ ("a" "Accept follow request" mastodon-profile--follow-request-accept)
+ ("r" "Reject follow request" mastodon-profile--follow-request-reject))
("Quit"
("q" "Quit mastodon and bury buffer." kill-this-buffer)
("Q" "Quit mastodon buffer and kill window." kill-buffer-and-window)))))))
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)
diff --git a/lisp/mastodon-tl.el b/lisp/mastodon-tl.el
index dac3e66..7b0afeb 100644
--- a/lisp/mastodon-tl.el
+++ b/lisp/mastodon-tl.el
@@ -1163,6 +1163,8 @@ UPDATE-FUNCTION is used to recieve more toots."
(seconds-to-time 300)))
(funcall update-function json))
(mastodon-mode)
+ (when (equal endpoint "follow_requests")
+ (mastodon-profile-mode))
(with-current-buffer buffer
(setq mastodon-tl--buffer-spec
`(buffer-name ,buffer