diff options
author | Colin Okay <okay@toyful.space> | 2022-02-15 16:22:19 -0600 |
---|---|---|
committer | Colin Okay <okay@toyful.space> | 2022-02-15 16:22:19 -0600 |
commit | 4bb5e88cac5d9759f22c0601d2c0dfe593c46a5c (patch) | |
tree | 3c74a4d68c961b496875b035a47eb51c8f671211 | |
parent | 06ec0ee02e52321095a07eecd6d7b6ffcb6bd237 (diff) |
added flag endpoint
-rw-r--r-- | src/main.lisp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/main.lisp b/src/main.lisp index b05d7bc..ee04b2b 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -267,6 +267,13 @@ :oneliner oneliner :brief brief)))) +(defun flag-oneliner (oneliner &optional contributor) + (db:with-transaction () + (setf (flagged-by oneliner) (or contributor :anonymous)))) + +;;; DATABASE QUERIES + + (defun query-oneliners (&key tags notflagged limit) ;; inefficient but easy to express (let ((ols (oneliners-with-all-tags tags))) @@ -319,6 +326,12 @@ string) +(defun a-oneliner-id (string) + "An id of a oneliner instance " + (a:if-let (oneliner (db:store-object-with-id (parse-integer string))) + oneliner + (http-err 404))) + ;;; ENDPOINT DEFINITIONS (defendpoint* :post "/redeem/:invite an-invite-code:" @@ -369,6 +382,10 @@ (t ; else responde with 400 (http-err 400)))) +(defendpoint* :patch "/flag/:oneliner a-oneliner-id:" () () + (flag-oneliner oneliner (request-contributor)) + "true") + ;;; HELPERS (defun slot-name-of (class name) |