Skip to content

Commit

Permalink
Fix invalid json being sent (not escaping " and \n) for reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurenceWarne committed Aug 18, 2024
1 parent e2243da commit 9ad22db
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Set up Emacs
uses: purcell/setup-emacs@master
with:
version: ${{matrix.emacs_version}}
version: ${{ matrix.emacs_version }}

- name: Install Eldev
run: curl -fsSL https://raw.github.com/doublep/eldev/master/webinstall/github-eldev | sh
Expand Down
2 changes: 1 addition & 1 deletion finito-buffer.el
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ BOOK-ALIST is an alist of the format returned by `finito--create-book-alist'"
nil
'equal))
(bound-and-true-p finito--show-reviews))
(when review
(when (and review (not (s-blank-p review)))
(let ((review-header "Review:"))
(insert review-header)
(overlay-put (make-overlay (point) (- (point) (length review-header)))
Expand Down
2 changes: 1 addition & 1 deletion finito-graphql.el
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@

(defconst finito--review-book-mutation-variables
"{
\"review\": \"%s\",
\"review\": %s,
\"book\": {
\"title\": \"%s\",
\"authors\": %s,
Expand Down
14 changes: 9 additions & 5 deletions finito.el
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ CALLBACK is called with the parsed json if the request is successful.
If SYNC is non-nil make the request synchronous. If errors are detected
in the graphql response body, then call GRAPHQL-ERROR with the first error
as a symbol."
(when finito--debug (message "Finito request content: '%s'" request-plist))
(request (finito--host-uri)
:type "POST"
:headers (plist-get request-plist :headers)
Expand Down Expand Up @@ -840,17 +841,20 @@ Note this overwrites any existing review."
(coll-buf (current-buffer))
(buf (generate-new-buffer (format "%s Review" (alist-get 'title book)))))
(with-current-buffer buf
;; TODO make a major mode
(local-set-key
(kbd "C-c C-c")
(lambda () (interactive)
(finito--make-request
(finito--review-book-request-plist
book
(buffer-substring-no-properties (point-min) (point-max)))
(lambda (&rest _) (format "Added review for '%s'" (alist-get 'title book))))
(kill-buffer-and-window)
(with-current-buffer coll-buf
(revert-buffer)))))
(json-encode-string (buffer-substring-no-properties (point-min) (point-max))))
(lambda (&rest _)
(with-current-buffer coll-buf (revert-buffer))
(format "Added review for '%s'" (alist-get 'title book))))
(kill-buffer-and-window)))
(when-let ((review (alist-get 'review book)))
(insert review)))
(pop-to-buffer buf '(display-buffer-below-selected . nil))
(message "Use C-c C-c to submit the review"))))

Expand Down

0 comments on commit 9ad22db

Please sign in to comment.