moving to using a rust api
This commit is contained in:
parent
2d1424aeb2
commit
f00ed3a04c
12 changed files with 1044 additions and 272 deletions
229
src/main.lisp
229
src/main.lisp
|
@ -283,32 +283,94 @@ with the image attached to us"
|
|||
(uiop:println form)
|
||||
(let ((first-name (cdr (assoc "firstname" form :test 'string=)))
|
||||
(last-name (cdr (assoc "lastname" form :test 'string=))))
|
||||
(cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
'("chris@tfcconnection.org" "chris@cochrun.xyz")
|
||||
(format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
|
||||
(format nil "Mission Trip Form for ~a ~a" first-name last-name)
|
||||
:display-name "TFC ADMIN"
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
:attachments attachment
|
||||
:html-message
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Mission Trip Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Mission Trip Form for ~a ~a" first-name last-name))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (car row))
|
||||
(:td (trim-whitespace
|
||||
(cdr row)))))))))))
|
||||
(uiop:println "Mail sent!"))
|
||||
(not (cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
"chris@cochrun.xyz"
|
||||
(format nil "~a ~a filled out a Mission Trip Form!" first-name last-name)
|
||||
(format nil "Mission Trip Form for ~a ~a" first-name last-name)
|
||||
:display-name "TFC ADMIN"
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
:attachments attachment
|
||||
:html-message
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Mission Trip Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Mission Trip Form for ~a ~a" first-name last-name))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (trim-whitespace (car row)))
|
||||
(:td (trim-whitespace
|
||||
(cdr row)))))))))))))
|
||||
|
||||
(cl-smtp:send-email
|
||||
"mail.tfcconnection.org"
|
||||
"no-reply@mail.tfcconnection.org"
|
||||
"chris@cochrun.xyz"
|
||||
(format nil "~a ~a filled out a Mission Trip Form!" "Chris" "Ccohrun")
|
||||
"hi"
|
||||
:html-message
|
||||
(let ((form '(("age" . "150")
|
||||
("registration" . "later")
|
||||
("final-agreement" . "yes")
|
||||
("relevant-notes" . "")
|
||||
("attitude-toward-work" . "")
|
||||
("previous-trip-info" . "")
|
||||
("weaknesses" . "")
|
||||
("strengths" . "")
|
||||
("reasons-for-trip-choice" . "")
|
||||
("involvement-with-group" . "")
|
||||
("testimony" . "")
|
||||
("relationship-with-jesus" . "")
|
||||
("tripnotes" . "")
|
||||
("trip" . "New Mexico")
|
||||
("shirt" . "small")
|
||||
("tfcgroup" . "Phillipsburg")
|
||||
("churchattendanceother" . "")
|
||||
("churchattendance" . "yes")
|
||||
("church" . "")
|
||||
("pastorphone" . "9991112222")
|
||||
("pastorlastname" . "The White")
|
||||
("pastorfirstname" . "Gandalf")
|
||||
("grade" . "sophomore")
|
||||
("school" . "A cool one")
|
||||
("parentemail" . "bilbosmells@braggins.xyz")
|
||||
("email" . "chris@cochrun.xyz")
|
||||
("parentphone" . "8889990000")
|
||||
("cellphone" . "7853021664")
|
||||
("zip" . "67661")
|
||||
("state" . "Middle Earth")
|
||||
("city" . "The Shire")
|
||||
("street" . "1234 Bag End, 98 Hobbiton")
|
||||
("gender" . "Male")
|
||||
("birthdate" . "1873-11-23")
|
||||
("parentlastname" . "Braggins")
|
||||
("parentfirstname" . "Bilbo")
|
||||
("lastname" . "Braggins")
|
||||
("firstname" . "Frodo"))))
|
||||
(with-html-string
|
||||
(:doctype)
|
||||
(:html
|
||||
(:head (:title "TFC Mission Trip Form")
|
||||
(:style (apply #'lass:compile-and-write *mail-css*)))
|
||||
(:body
|
||||
(:h1 (format nil "Mission Trip Form for ~a ~a" "Chris" "Ccohrun"))
|
||||
(:hr)
|
||||
(:table
|
||||
(loop for row in form
|
||||
do (:tr
|
||||
(:th (trim-whitespace (car row)))
|
||||
(:td (trim-whitespace
|
||||
(cdr row))))))))))
|
||||
:ssl :tls
|
||||
:authentication '(:login "no-reply@mail.tfcconnection.org" "r9f36mNZFtiW4f")
|
||||
)
|
||||
|
||||
(defun mail-form (form attachment)
|
||||
"Takes the form as an alist and sends a table formatted email
|
||||
|
@ -450,65 +512,70 @@ with the image attached"
|
|||
((eq request-type :post)
|
||||
(loop :for i :in parts
|
||||
:do (let* ((content-disposition
|
||||
(nth 1
|
||||
(serapeum:lines i
|
||||
:eol-style
|
||||
:crlf
|
||||
:honor-crlf t)))
|
||||
(start (if content-disposition
|
||||
(position #\" content-disposition)))
|
||||
(end (if start
|
||||
(position #\" content-disposition
|
||||
:start (1+ start)) nil))
|
||||
(name (if end
|
||||
(if start
|
||||
(subseq content-disposition
|
||||
(1+ start) end) nil) nil))
|
||||
(content
|
||||
(if (string= name "image")
|
||||
(butlast
|
||||
(rest
|
||||
(rest
|
||||
(rest
|
||||
(rest
|
||||
(serapeum:lines i
|
||||
:eol-style
|
||||
:crlf
|
||||
:honor-crlf t
|
||||
:keep-eols t))))))
|
||||
(trim-whitespace
|
||||
(car
|
||||
(butlast
|
||||
(rest
|
||||
(rest
|
||||
(rest
|
||||
(serapeum:lines i :eol-style :crlf
|
||||
:honor-crlf t
|
||||
:keep-eols t)))))))))
|
||||
(file-start
|
||||
(if (string= name "image")
|
||||
(position #\" content-disposition
|
||||
:start 44)))
|
||||
(file-end
|
||||
(if file-start
|
||||
(position #\" content-disposition
|
||||
:start (1+ file-start)) nil))
|
||||
(image-file-name
|
||||
(if (string= name "image")
|
||||
(subseq content-disposition
|
||||
(1+ file-start) file-end) nil)))
|
||||
(nth 1
|
||||
(serapeum:lines i
|
||||
:eol-style
|
||||
:crlf
|
||||
:honor-crlf t)))
|
||||
(start (if content-disposition
|
||||
(position #\" content-disposition)))
|
||||
(end (if start
|
||||
(position #\" content-disposition
|
||||
:start (1+ start)) nil))
|
||||
(name (if end
|
||||
(if start
|
||||
(subseq content-disposition
|
||||
(1+ start) end) nil) nil))
|
||||
(content
|
||||
(if (string= name "image")
|
||||
nil
|
||||
;; (butlast
|
||||
;; (rest
|
||||
;; (rest
|
||||
;; (rest
|
||||
;; (rest
|
||||
;; (serapeum:lines i
|
||||
;; :eol-style
|
||||
;; :crlf
|
||||
;; :honor-crlf t
|
||||
;; :keep-eols t))))))
|
||||
(trim-whitespace
|
||||
(car
|
||||
(butlast
|
||||
(rest
|
||||
(rest
|
||||
(rest
|
||||
(serapeum:lines i :eol-style :crlf
|
||||
:honor-crlf t
|
||||
:keep-eols t)))))))))
|
||||
(file-start
|
||||
(if (string= name "image")
|
||||
(position #\" content-disposition
|
||||
:start 44)))
|
||||
(file-end
|
||||
(if file-start
|
||||
(position #\" content-disposition
|
||||
:start (1+ file-start)) nil))
|
||||
(image-file-name
|
||||
(if (string= name "image")
|
||||
(subseq content-disposition
|
||||
(1+ file-start) file-end) nil)))
|
||||
|
||||
(if name
|
||||
(if (string= name "image")
|
||||
(if (uiop:file-exists-p image-file-name)
|
||||
(progn
|
||||
(save-string-file
|
||||
(apply #'concatenate 'string content)
|
||||
image-file-name)
|
||||
(setq form-list (acons name image-file-name form-list))
|
||||
(setf attachment image-file-name)))
|
||||
(when (stringp content)
|
||||
(progn
|
||||
(if (not (uiop:file-exists-p image-file-name))
|
||||
(save-string-file
|
||||
(apply #'concatenate 'string content)
|
||||
image-file-name))
|
||||
(setf attachment image-file-name)
|
||||
(delete-file image-file-name)))
|
||||
(setq form-list (acons name content form-list))))))
|
||||
(if (mail-mt-form form-list attachment)
|
||||
(format nil "thankyou"))))))
|
||||
(progn
|
||||
(uiop:println "Mail sent")
|
||||
(format nil "thankyou")))))))
|
||||
|
||||
(hunchentoot:define-easy-handler (respond :uri "/health-form") ()
|
||||
(setf (hunchentoot:content-type*) "plain/text")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue