aboutsummaryrefslogtreecommitdiff
path: root/sx-question.el
diff options
context:
space:
mode:
authorArtur Malabarba <bruce.connor.am@gmail.com>2015-02-03 13:13:19 -0200
committerArtur Malabarba <bruce.connor.am@gmail.com>2015-02-03 13:13:19 -0200
commitd725f48f4acea6934c71fedfc7b35adc9f96a7b5 (patch)
tree6eb08e5735fec3eac090d4fa587d532ab24703d3 /sx-question.el
parent148da420d9f464f3cc8046fed99a103af0fd7bed (diff)
parenta2d526c4b12ffa1cece78be7e6bfedf0b2b60576 (diff)
Merge branch 'master' into more-tests
Diffstat (limited to 'sx-question.el')
-rw-r--r--sx-question.el20
1 files changed, 20 insertions, 0 deletions
diff --git a/sx-question.el b/sx-question.el
index 1e3a02c..1df4900 100644
--- a/sx-question.el
+++ b/sx-question.el
@@ -72,6 +72,26 @@ If ANSWER-ID doesn't exist on SITE, raise an error."
(error "Couldn't find answer %S in %S"
answer-id site))))
+(defun sx-question-get-from-comment (site comment-id)
+ "Get question from SITE to which COMMENT-ID belongs.
+If COMMENT-ID doesn't exist on SITE, raise an error.
+
+Note this requires two API requests. One for the comment and one
+for the post."
+ (let ((res (sx-method-call 'comments
+ :id comment-id
+ :site site
+ :auth t
+ :filter sx-browse-filter)))
+ (unless (vectorp res)
+ (error "Couldn't find comment %S in %S" comment-id site))
+ (sx-assoc-let (elt res 0)
+ (funcall (if (string= .post_type "answer")
+ #'sx-question-get-from-answer
+ #'sx-question-get-question)
+ .site_par
+ .post_id))))
+
;;; Question Properties