diff options
-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) |