MCPcopy Create free account
hub / github.com/GoMudEngine/GoMud / apiAdminListMudmail

Method apiAdminListMudmail

modules/mudmail/admin.go:53–75  ·  view source on GitHub ↗

apiAdminListMudmail handles GET /admin/api/v1/mudmail?user_id= Returns summary entries (no body) for the given user. user_id is required.

(r *http.Request)

Source from the content-addressed store, hash-verified

51// Returns summary entries (no body) for the given user.
52// user_id is required.
53func (m *MudmailModule) apiAdminListMudmail(r *http.Request) (int, bool, any) {
54 type result struct {
55 Messages []adminSummaryEntry `json:"messages"`
56 }
57
58 userIdStr := r.URL.Query().Get("user_id")
59 if userIdStr == "" {
60 return http.StatusBadRequest, false, map[string]string{"error": "user_id query param is required"}
61 }
62 userId, err := strconv.Atoi(userIdStr)
63 if err != nil || userId <= 0 {
64 return http.StatusBadRequest, false, map[string]string{"error": "invalid user_id"}
65 }
66
67 username, inbox := m.inboxForUser(userId)
68
69 entries := make([]adminSummaryEntry, 0, len(inbox))
70 for _, msg := range inbox {
71 entries = append(entries, toSummaryEntry(userId, username, msg))
72 }
73
74 return http.StatusOK, true, result{Messages: entries}
75}
76
77// apiAdminGetMudmailBody handles GET /admin/api/v1/mudmail-body/{user_id}/{timestamp}
78// Returns the full message data for a single message identified by user_id and

Callers

nothing calls this directly

Calls 3

inboxForUserMethod · 0.95
toSummaryEntryFunction · 0.85
GetMethod · 0.45

Tested by

no test coverage detected