diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 11:09:13 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 11:16:43 -0400 |
commit | 3b781f850c825813fba4719cd5e082d010389eeb (patch) | |
tree | 6a32a48ec50759634da1fd6814d6f87a8ea5cbd5 /lisp/mastodon-toot.el | |
parent | d619ea51ef8f29be33d55938147feff42afce0d3 (diff) |
Favourite toots from timelines
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index e567cc6..eac1193 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -70,23 +70,37 @@ STATUS is passed by `url-retrieve'." (propertize marker 'face 'success))))) -(defun mastodon-toot--boost-triage (response) - "Parse response code from RESPONSE buffer." +(defun mastodon-toot--action-triage (response callback) + "Parse response code from RESPONSE buffer. + +Execute CALLBACK function if response was OK." (let ((status (with-current-buffer response (mastodon--response-code)))) (if (string-prefix-p "2" status) - (mastodon-toot--action-success "B") + (funcall callback) (switch-to-buffer response)))) -(defun mastodon-toot--boost () - "Boost toot at point." - (interactive) +(defun mastodon-toot--action (action callback) + "Take action on toot at point." (let* ((id (mastodon-tl--property 'toot-id)) (url (mastodon--api-for (concat "statuses/" (number-to-string id) - "/reblog")))) + "/" + action)))) (let ((response (mastodon-http--post url nil nil))) - (mastodon-toot--boost-triage response)))) + (mastodon-toot--action-triage response callback)))) + +(defun mastodon-toot--boost () + "Boost toot at `point'." + (interactive) + (let ((callback (lambda () (mastodon-toot--action-success "B")))) + (mastodon-toot--action "reblog" callback))) + +(defun mastodon-toot--favourite () + "Favourite toot at `point'." + (interactive) + (let ((callback (lambda () (mastodon-toot--action-success "F")))) + (mastodon-toot--action "favourite" callback))) (defvar mastodon-toot-mode-map (let ((map (make-sparse-keymap))) |