diff options
author | Griffin Smith <grfn@gws.fyi> | 2020-07-23T22·56-0400 |
---|---|---|
committer | glittershark <grfn@gws.fyi> | 2020-07-24T01·01+0000 |
commit | add588e634a3ddd798710e9f95fec271903db441 (patch) | |
tree | 090d58cf047e833d20293d1cf77f64c467b8613a /web | |
parent | 943a4c92149b366d24a7485f0ff547fbbedc5d44 (diff) |
feat(web/panettone): Disallow comments with an empty body r/1449
Change-Id: Ic77a0caf419389e8460bf7e5688293f3a588caa4 Reviewed-on: https://cl.tvl.fyi/c/depot/+/1405 Tested-by: BuildkiteCI Reviewed-by: kanepyork <rikingcoding@gmail.com>
Diffstat (limited to 'web')
-rw-r--r-- | web/panettone/src/panettone.lisp | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/web/panettone/src/panettone.lisp b/web/panettone/src/panettone.lisp index 5c8afc2ca7e9..87c7b0659e35 100644 --- a/web/panettone/src/panettone.lisp +++ b/web/panettone/src/panettone.lisp @@ -429,16 +429,20 @@ updated issue" ("/issues/:id/comments" :decorators (@auth) :method :post) (&path (id 'integer) &post body) - (handler-case - (progn - (cl-prevalence:execute-transaction - (add-comment *p-system* id - :body body - :author-dn (dn *user*))) - (cl-prevalence:snapshot *p-system*) - (hunchentoot:redirect (format nil "/issues/~A" id))) - (issue-not-found (_) - (render/not-found "Issue")))) + (flet ((redirect-to-issue () + (hunchentoot:redirect (format nil "/issues/~A" id)))) + (if (string= body "") + (redirect-to-issue) + (handler-case + (progn + (cl-prevalence:execute-transaction + (add-comment *p-system* id + :body body + :author-dn (dn *user*))) + (cl-prevalence:snapshot *p-system*) + (redirect-to-issue)) + (issue-not-found (_) + (render/not-found "Issue")))))) (defroute close-issue ("/issues/:id/close" :decorators (@auth) |