summaryrefslogtreecommitdiff
path: root/haunt
diff options
context:
space:
mode:
authorJakob L. Kreuze <zerodaysfordays@sdf.org>2023-03-11 16:51:46 -0500
committerJakob L. Kreuze <zerodaysfordays@sdf.org>2023-03-11 16:51:55 -0500
commit4d07077daedc30271be69c86c855795affdea860 (patch)
tree7ac343c51a930b86b23507ca38ddd2ef620dde26 /haunt
parent45f5c3c0f8e745bc2392a8c5821f09913604da04 (diff)
Address parsing issues in `put-reaction' endpoint
Diffstat (limited to 'haunt')
-rw-r--r--haunt/api.scm1
-rw-r--r--haunt/jakob/dynamic/capabilities/comments.scm11
2 files changed, 5 insertions, 7 deletions
diff --git a/haunt/api.scm b/haunt/api.scm
index 810b905..1cf2b44 100644
--- a/haunt/api.scm
+++ b/haunt/api.scm
@@ -73,6 +73,7 @@
('(GET "challenge" "captcha") make-captcha-challenge!)
('(GET "comments") get-comments)
(('POST "comment") put-comment)
+ (('POST "comment" "react") put-reaction)
(('GET "gallery") get-gallery)
(('GET "gallery" "image") get-image)
(('GET "rsvp" "event-info") get-event-info)
diff --git a/haunt/jakob/dynamic/capabilities/comments.scm b/haunt/jakob/dynamic/capabilities/comments.scm
index 98560b0..1da8abb 100644
--- a/haunt/jakob/dynamic/capabilities/comments.scm
+++ b/haunt/jakob/dynamic/capabilities/comments.scm
@@ -188,15 +188,12 @@ This is a wrapper around `get-comments-by-slug'."
(define (valid-reaction? form-data)
(and (assoc "id" form-data)
(assoc "reaction" form-data)))
- (let* ((query-string (uri-query (request-uri request)))
- (form-data (if query-string
- (decode-form query-string)
- '())))
+ (let ((form-data (decode-form body)))
(unless (assoc "id" form-data) (panic "missing param `id'"))
(unless (assoc "reaction" form-data) (panic "missing param `reaction'"))
- (let ((id (assoc-value form-data "id"))
- (reaction (assoc-value form-data "reaction"))
- (reactions (comment-reactions id)))
+ (let* ((id (assoc-value form-data "id"))
+ (reaction (assoc-value form-data "reaction"))
+ (reactions (comment-reactions id)))
(unless reactions (panic "no such comment"))
(set-reactions id (add-reaction reactions reaction))
(values '((content-type . (application/json)))