handleRaw returns the original RFC 822 source of an SMTP message.
(store event.Store)
| 192 | |
| 193 | // handleRaw returns the original RFC 822 source of an SMTP message. |
| 194 | func handleRaw(store event.Store) http.HandlerFunc { |
| 195 | return func(w http.ResponseWriter, r *http.Request) { |
| 196 | uuid := r.PathValue("uuid") |
| 197 | ev, err := store.FindByUUID(r.Context(), uuid) |
| 198 | if err != nil { |
| 199 | smtpError(w, err.Error(), http.StatusInternalServerError) |
| 200 | return |
| 201 | } |
| 202 | if ev == nil || ev.Type != "smtp" { |
| 203 | smtpError(w, "message not found", http.StatusNotFound) |
| 204 | return |
| 205 | } |
| 206 | |
| 207 | var email ParsedEmail |
| 208 | if err := json.Unmarshal(ev.Payload, &email); err != nil { |
| 209 | smtpError(w, "failed to parse message", http.StatusInternalServerError) |
| 210 | return |
| 211 | } |
| 212 | |
| 213 | w.Header().Set("Content-Type", "message/rfc822") |
| 214 | w.Write([]byte(email.Raw)) //nolint:errcheck |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | // handleLinks extracts every hyperlink from a message's HTML and text parts. |
| 219 | func handleLinks(store event.Store) http.HandlerFunc { |
no test coverage detected