Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2021
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lisp 0.87 KB | None | 0 0
  1. (de event/add ()
  2.     (httpHead "application/json" 0)
  3.     (let (Body *body
  4.                JsonBody (json-decode Body)
  5.                Token (getFromBody "token" JsonBody)
  6.                Origin (getFromBody "origin" JsonBody)
  7.                Now (now)
  8.                OriginDB (db 'name '+EventOrigin Origin)
  9.                Content (getFromBody "content" JsonBody))
  10.       (msg "Here")
  11.       (if (and Token Origin Now Content OriginDB)
  12.           (let (EventResult (addEvent Origin Content Token))
  13.             (msg EventResult)
  14.             (cond
  15.              ((match '(Ok . @Resp) EventResult) (jsonResponse NIL (cons "msg" '@Resp)))
  16.              ((match '(Error . @Resp) EventResult) (jsonResponse T (cons "errorMsg" '@Resp)))
  17.              (T (jsonResponse (cons "errorMsg" "Cannot parse response from DB")))))
  18.         (jsonResponse T (cons "errorMsg" "Missing param"))
  19.         )))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement