cl-matrix/src/matrix.lisp

70 lines
1.5 KiB
Common Lisp

(in-package :cl-matrix)
(defstruct matrix-input
path-args
access-token
json-body
user)
(define-condition matrix-error (error)
((errcode :reader errcode)
(msg :initarg :msg :initform "" :reader msg)))
(defmacro make-matrix-errors (&rest names)
(loop for name-maybe in names
for name = (string name-maybe)
for snake = (loop for ch across name
with result = (copy-seq name)
for i upfrom 0
do (if (eql ch #\-) (setf (aref result i) #\_))
finally (return result))
collecting `(define-condition ,(intern (format nil "~a-ERROR" (string-upcase name))) (matrix-error)
((errcode :initform ,(format nil "M_~a" snake))))
into defines
finally (return (append '(progn) defines))))
(make-matrix-errors
forbidden
unknown-token
missing-token
user-locked
user-suspended
bad-json
not-json
not-found
limit-exceeded
unrecognized
unknown
unauthorized
user-deactivated
user-in-user
invalid-username
room-in-use
invalid-room-state
threepid-in-use
threepid-not-found
threepid-auth-failed
threepid-denied
server-not-trusted
unsupported-room-version
incompatible-room-version
bad-state
guest-access-forbidden
captcha-needed
captcha-invalid
missing-param
invalid-param
too-large
exclusive
resource-limit-exceeded
cannot-leave-server-notice-room
threepid-medium-not-supported
threepid-in-use)
(defun versions (input)
(json-response 200 '(:versions ("v1.1" "v1.2" "v1.3" "v1.4" "v1.5" "v1.6" "v1.7" "v1.8" "v1.9" "v1.10" "v1.11" "v1.12" "v1.13"))))
(defun get-logins (input)
(log-info input))