diff options
author | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 09:07:03 -0400 |
---|---|---|
committer | Johnson Denen <johnson.denen@gmail.com> | 2017-04-18 10:44:40 -0400 |
commit | b10430e7d42d3c07f4e71ed7375d256cd5fccbf8 (patch) | |
tree | 67b836f431f6a5db8d77f2166c449af4307056b1 /lisp/mastodon-toot.el | |
parent | 9c2d6230993340d13f85be99dcc128e09e73058a (diff) |
Add boost feature to timelines
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r-- | lisp/mastodon-toot.el | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el index 481a187..ff20434 100644 --- a/lisp/mastodon-toot.el +++ b/lisp/mastodon-toot.el @@ -61,6 +61,27 @@ STATUS is passed by `url-retrieve'." (interactive) (kill-buffer-and-window)) +(defun mastodon-toot--property (prop) + "Get property PROP for toot at point." + (or (get-text-property (point) prop) + (progn + (mastodon-tl--goto-next-toot) + (get-text-property (point) prop)))) + +;; TODO extract success callback +(defun mastodon-toot--boost () + "Boost toot at point." + (interactive) + (let* ((id (mastodon-toot--property 'toot-id)) + (url (mastodon--api-for (concat "statuses/" + (number-to-string id) + "/reblog")))) + (let ((response (mastodon-http--post url nil nil))) + (with-current-buffer response + (if (string-prefix-p "2" (mastodon--response-code)) + (message "Boosted!") + (switch-to-buffer response)))))) + (defvar mastodon-toot-mode-map (let ((map (make-sparse-keymap))) (define-key map (kbd "C-c C-c") #'mastodon-toot-send) |