diff options
Diffstat (limited to 'haunt/jakob/dynamic/capabilities/comments.scm')
| -rw-r--r-- | haunt/jakob/dynamic/capabilities/comments.scm | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/haunt/jakob/dynamic/capabilities/comments.scm b/haunt/jakob/dynamic/capabilities/comments.scm index 98560b0..996c549 100644 --- a/haunt/jakob/dynamic/capabilities/comments.scm +++ b/haunt/jakob/dynamic/capabilities/comments.scm @@ -188,16 +188,14 @@ 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))) - (unless reactions (panic "no such comment")) + (let* ((id (assoc-value form-data "id")) + (reaction (assoc-value form-data "reaction")) + (reactions (comment-reactions id))) + (unless id (panic "no such comment")) + (unless (emoji? reaction) (panic "invalid reaction")) (set-reactions id (add-reaction reactions reaction)) (values '((content-type . (application/json))) (scm->json-string `((success . #t))))))) |