aboutsummaryrefslogtreecommitdiff
path: root/lisp/mastodon-toot.el
diff options
context:
space:
mode:
authorJohnson Denen <johnson.denen@gmail.com>2017-04-20 11:41:41 -0400
committerJohnson Denen <johnson.denen@gmail.com>2017-04-20 12:30:02 -0400
commitdf6320f5174e610f1eb281ff619fd88a5fb1ba6a (patch)
tree2735f2289ae25436ea6172c38cfa590fce8cd5de /lisp/mastodon-toot.el
parent9a705f3884168bf9ac0708b64f333b3893f0d0d8 (diff)
Close #11 with new callbacks
Diffstat (limited to 'lisp/mastodon-toot.el')
-rw-r--r--lisp/mastodon-toot.el37
1 files changed, 17 insertions, 20 deletions
diff --git a/lisp/mastodon-toot.el b/lisp/mastodon-toot.el
index 93980f0..13e23b7 100644
--- a/lisp/mastodon-toot.el
+++ b/lisp/mastodon-toot.el
@@ -44,24 +44,7 @@ STATUS is passed by `url-retrieve'."
(mastodon--http-response-triage status
(lambda () (switch-to-buffer (current-buffer))))) ;; FIXME
-(defun mastodon-toot-send ()
- "Kill new-toot buffer/window and POST contents to the Mastodon instance."
- (interactive)
- (let* ((toot (buffer-string))
- (endpoint (mastodon--api-for "statuses"))
- (args `(("status" . ,toot)
- ("in_reply_to_id" . ,mastodon-toot--reply-to-id))))
- (progn
- (kill-buffer-and-window)
- (setq mastodon-toot--reply-to-id nil)
- (mastodon--http-post endpoint
- 'mastodon-toot--send-triage
- args
- `(("Authorization" . ,(concat
- "Bearer "
- (mastodon--access-token))))))))
-
-(defun mastodon-toot-cancel ()
+(defun mastodon-toot--cancel ()
"Kill new-toot buffer/window. Does not POST content to Mastodon."
(interactive)
(setq mastodon-toot--reply-to-id nil)
@@ -94,6 +77,20 @@ Execute CALLBACK function if response was OK."
(let ((response (mastodon-http--post url nil nil)))
(mastodon-toot--action-triage response callback))))
+(defun mastodon-toot--send ()
+ "Kill new-toot buffer/window and POST contents to the Mastodon instance."
+ (interactive)
+ (let* ((toot (buffer-string))
+ (endpoint (mastodon--api-for "statuses"))
+ (args `(("status" . ,toot)
+ ("in_reply_to_id" . ,mastodon-toot--reply-to-id))))
+ (progn
+ (kill-buffer-and-window)
+ (setq mastodon-toot--reply-to-id nil)
+ (let ((response (mastodon-http--post endpoint args nil)))
+ (mastodon-http--triage response
+ (lambda () (message "Toot toot!")))))))
+
(defun mastodon-toot--boost ()
"Boost toot at `point'."
(interactive)
@@ -121,8 +118,8 @@ Execute CALLBACK function if response was OK."
(defvar mastodon-toot-mode-map
(let ((map (make-sparse-keymap)))
- (define-key map (kbd "C-c C-c") #'mastodon-toot-send)
- (define-key map (kbd "C-c C-k") #'mastodon-toot-cancel)
+ (define-key map (kbd "C-c C-c") #'mastodon-toot--send)
+ (define-key map (kbd "C-c C-k") #'mastodon-toot--cancel)
map)
"Keymap for `mastodon-toot-mode'.")