From 4bb5e88cac5d9759f22c0601d2c0dfe593c46a5c Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Tue, 15 Feb 2022 16:22:19 -0600 Subject: added flag endpoint --- src/main.lisp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'src') 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) -- cgit v1.2.3