From 55cbb146e64eac0d5ce5188f66551aa1a6dd9e97 Mon Sep 17 00:00:00 2001 From: Colin Okay Date: Tue, 15 Feb 2022 11:17:02 -0600 Subject: adding oneliners --- src/main.lisp | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) (limited to 'src/main.lisp') diff --git a/src/main.lisp b/src/main.lisp index ebd07c1..97e0ffc 100644 --- a/src/main.lisp +++ b/src/main.lisp @@ -289,6 +289,26 @@ (db:with-transaction () (make-instance 'api-access :contributor contributor))) +(defun make-new-oneliner (contributor plist) + (print (list :contributor contributor :plist plist)) + (with-plist + (oneliner commands brief description) plist + (print (list oneliner commands brief description)) + (unless brief + (http-err 400 "Oneliner requires a breif description")) + (unless oneliner + (http-err 400 "Oneliner cannot be blank")) + (unless commands + (http-err 400 "This oneliner does not seem to involve any commands")) + (db:with-transaction () + (make-instance 'oneliner + :created-by contributor + :description (or description "") + :commands commands + :oneliner oneliner + :brief brief)))) + + ;;; ROUTE VARIABLE AND PARAMATER PARSERS (defun an-int (string) @@ -362,7 +382,8 @@ (defendpoint* :post "/add-oneliner" () (:auth t) - ) + (make-new-oneliner (request-contributor) (lzb:request-body)) + "true") ;; (defendpoint* :get "/search" ((commands a-csl) ;; (keywords a-csl ) @@ -527,8 +548,8 @@ names. NAME must be a symbol or a string." (jonathan:*null-value* :null)) (jonathan:to-json thing))) -;; (defun request-contributor () -;; (a:when-let (access (access-by-token (lzb:request-cookie +auth-cookie-name+))) -;; (api-contributor access))) +(defun request-contributor () + (a:when-let (access (access-by-token (lzb:request-cookie +auth-cookie-name+))) + (api-contributor access))) -- cgit v1.2.3