Start of storing stuff

parent 50bf0756
......@@ -2,12 +2,15 @@
(require html-writing
net/url
net/uri-codec
json
web-server/servlet
web-server/servlet-env
web-server/dispatch
racket/runtime-path
magenc/install-factory)
magenc/install-factory
magenc/memory-store
magenc/get-put)
;;; Utilities
;;; =========
......@@ -113,6 +116,48 @@
'(p "Outbox goes here!"))))
(define (post-note req)
;;; Process form data
(define form-data
(form-urlencoded->alist
(bytes->string/utf-8 (request-post-data/raw req))))
;; TODO: Properly signal user about problem
(match-define (cons _ to)
(assoc 'to form-data))
(match-define (cons _ content)
(assoc 'content form-data))
(define to-addrs-strs
(string-split to))
(define to-addrs-urls
(map string->url to-addrs-strs))
;;; Now generate note and create structures
(define note
`#hasheq((type . "Note")
(content . ,content)
(attributed-to . ,(golem-absolute-url-str actor-profile))))
(define note-str
(json->string note))
(define note-url
(call-with-input-string note-str
(lambda (p)
(magenc-put! p (magenc-store)))))
(define create
`#hasheq((type . "Create")
(object . ,(url->string note-url))
;; not strictly necessary, but good to be kept in the loop :)
(to . ,to-addrs-strs)))
(define create-str
(json->string create))
(define create-url
(call-with-input-string create-str
(lambda (p)
(magenc-put! p (magenc-store)))))
(displayln note-str)
(displayln note-url)
(displayln create-str)
(displayln create-url)
(render-ok '(p "Hi there")))
(define (serve-encrypted-object req enc-hash-str)
......@@ -221,4 +266,4 @@
(install-default-factories!)
(main #:users-name "Alice"
#:db-conn 'TODO
#:magenc-store 'TODO))
#:magenc-store (new memory-store%)))
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment