aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-01-04 16:51:17 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-01-04 17:07:14 -0200
commitbfb0c17ee4bb63099f18f031d0ddeb9d62f18ded (patch)
treeb2143f19a1c9321cdb3d1ea0b388616232b2b0eb
parente1a57f49379fa9345b662a721941edd7371db60b (diff)
Implement favoriting
-rw-r--r--sx-interaction.el18
1 files changed, 18 insertions, 0 deletions
diff --git a/sx-interaction.el b/sx-interaction.el
index 3877035..17c23bd 100644
--- a/sx-interaction.el
+++ b/sx-interaction.el
@@ -189,6 +189,24 @@ If WINDOW nil, the window is decided by
(switch-to-buffer sx-question-mode--buffer))))
+;;; Favoriting
+(defun sx-favorite (data &optional undo)
+ "Favorite question given by DATA.
+Interactively, it is guessed from context at point.
+With the UNDO prefix argument, unfavorite the question instead."
+ (interactive (list (sx--error-if-unread (sx--data-here))
+ current-prefix-arg))
+ (sx-assoc-let data
+ (sx-method-call 'questions
+ :id .question_id
+ :submethod (if undo 'favorite/undo 'favorite)
+ :auth 'warn
+ :site .site_par
+ :url-method "POST"
+ :filter sx-browse-filter)))
+(defalias 'sx-star #'sx-favorite)
+
+
;;; Voting
(defun sx-toggle-upvote (data)
"Apply or remove upvote from DATA.