aboutsummaryrefslogtreecommitdiff
path: root/src/main.lisp
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.lisp')
-rw-r--r--src/main.lisp29
1 files changed, 25 insertions, 4 deletions
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)))