all repos — navani @ c0119bb48c0e5fba30d1a838d623d8aaed2b1eca

forlater's primary mail processing service

Add more logging
Anirudh Oppiliappan x@icyphox.sh
Wed, 15 Sep 2021 16:29:00 +0530
commit

c0119bb48c0e5fba30d1a838d623d8aaed2b1eca

parent

ac7cf9514f9fa09c55057e16de23c946e6abcb05

1 files changed, 5 insertions(+), 4 deletions(-)

jump to
M main.gomain.go

@@ -15,6 +15,7 @@ http.HandleFunc("/webhook", func(w http.ResponseWriter, r *http.Request) {

m := mail.Mail{} json.NewDecoder(r.Body).Decode(&m) body, err := mail.MailBody(m.Parts) + log.Printf("recieved webhook: %v\n", m) if err != nil { log.Println(err) }

@@ -22,25 +23,25 @@

for _, u := range distinct(mail.ExtractURLs(body)) { parsedURL, err := url.Parse(u) if err != nil { - log.Println(err) + log.Printf("url parse: %s\n", err) } f, err := reader.Fetch(parsedURL.String()) if err != nil { - log.Println(err) + log.Printf("reader fetch: %s\n", err) } article, err := reader.Readable(f, parsedURL) if err != nil { - log.Println(err) + log.Printf("not readable: %s\n", err) } err = mail.SendArticle(&article, m.From) if err != nil { log.Println(err) } + log.Printf("sent mail to %s: %s\n", m.From, article.Title) } - log.Printf("sent mail to %s\n", m.From) w.WriteHeader(204) })