MCPcopy Create free account
hub / github.com/buggregator/server / handleRaw

Function handleRaw

modules/smtp/api.go:194–216  ·  view source on GitHub ↗

handleRaw returns the original RFC 822 source of an SMTP message.

(store event.Store)

Source from the content-addressed store, hash-verified

192
193// handleRaw returns the original RFC 822 source of an SMTP message.
194func 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.
219func handleLinks(store event.Store) http.HandlerFunc {

Callers 1

registerSMTPAPIFunction · 0.85

Calls 2

smtpErrorFunction · 0.85
FindByUUIDMethod · 0.65

Tested by

no test coverage detected