MCPcopy Create free account
hub / github.com/coder/coder / handleMessages

Method handleMessages

scaletest/smtpmock/server.go:159–182  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request)

Source from the content-addressed store, hash-verified

157}
158
159func (s *Server) handleMessages(w http.ResponseWriter, r *http.Request) {
160 email := r.URL.Query().Get("email")
161 msgs := s.smtpServer.Messages()
162
163 var summaries []EmailSummary
164 for _, msg := range msgs {
165 recipients := msg.RcpttoRequestResponse()
166 if !matchesRecipient(recipients, email) {
167 continue
168 }
169
170 summary, err := parseEmailSummary(msg.MsgRequest())
171 if err != nil {
172 s.logger.Warn(r.Context(), "failed to parse email summary", slog.Error(err))
173 continue
174 }
175 summaries = append(summaries, summary)
176 }
177
178 w.Header().Set("Content-Type", "application/json")
179 if err := json.NewEncoder(w).Encode(summaries); err != nil {
180 s.logger.Warn(r.Context(), "failed to encode JSON response", slog.Error(err))
181 }
182}
183
184func matchesRecipient(recipients [][]string, email string) bool {
185 if email == "" {

Callers

nothing calls this directly

Calls 8

matchesRecipientFunction · 0.85
parseEmailSummaryFunction · 0.85
EncodeMethod · 0.80
GetMethod · 0.65
ContextMethod · 0.65
SetMethod · 0.65
ErrorMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected