summaryrefslogtreecommitdiff
path: root/dynamic/capabilities/comments.scm
diff options
context:
space:
mode:
Diffstat (limited to 'dynamic/capabilities/comments.scm')
-rw-r--r--dynamic/capabilities/comments.scm40
1 files changed, 40 insertions, 0 deletions
diff --git a/dynamic/capabilities/comments.scm b/dynamic/capabilities/comments.scm
new file mode 100644
index 0000000..d7dc1fa
--- /dev/null
+++ b/dynamic/capabilities/comments.scm
@@ -0,0 +1,40 @@
+;;; Copyright © 2019 - 2022 Jakob L. Kreuze <zerodaysfordays@sdf.org>
+;;;
+;;; This program is free software; you can redistribute it and/or
+;;; modify it under the terms of the GNU General Public License as
+;;; published by the Free Software Foundation; either version 3 of the
+;;; License, or (at your option) any later version.
+;;;
+;;; This program is distributed in the hope that it will be useful,
+;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
+;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+;;; General Public License for more details.
+;;;
+;;; You should have received a copy of the GNU General Public License
+;;; along with this program. If not, see
+;;; <http://www.gnu.org/licenses/>.
+
+(define challenges (make-hash-table))
+(define conn (connect-to-postgres-paramstring "dbname=jakob_comments"))
+
+(define (get-comments request body)
+ (values '((content-type . (application/json)))
+ (scm->json-string
+ '((title . "whoa buddy")
+ (author . "Jakob Kreuze")
+ (date . "2022-03-27")
+ (text . "bad take, bad take!")))))
+
+(define (put-comment request body)
+ (display (decode-form body))
+ (newline)
+ (values '((content-type . (text/plain))) "Hello hacker!"))
+
+(define (make-challenge request body)
+ (let-values (((uuid value image) (new-captcha)))
+ (hash-set! challenges uuid value)
+ (hash-for-each (lambda (x y) (display x) (newline)) challenges)
+ (values `((content-type . (application/base64))
+ (access-control-allow-origin . "*")
+ (x-captcha-id . ,uuid))
+ (base64-encode image))))