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

Method apiAdminGetMudmailBody

modules/mudmail/admin.go:80–102  ·  view source on GitHub ↗

apiAdminGetMudmailBody handles GET /admin/api/v1/mudmail-body/{user_id}/{timestamp} Returns the full message data for a single message identified by user_id and unix timestamp.

(r *http.Request)

Source from the content-addressed store, hash-verified

78// Returns the full message data for a single message identified by user_id and
79// unix timestamp.
80func (m *MudmailModule) apiAdminGetMudmailBody(r *http.Request) (int, bool, any) {
81 userIdStr := r.PathValue("user_id")
82 timestampStr := r.PathValue("timestamp")
83
84 userId, err := strconv.Atoi(userIdStr)
85 if err != nil || userId <= 0 {
86 return http.StatusBadRequest, false, map[string]string{"error": "invalid user_id"}
87 }
88 dateSentUs, err := strconv.ParseInt(timestampStr, 10, 64)
89 if err != nil {
90 return http.StatusBadRequest, false, map[string]string{"error": "invalid timestamp"}
91 }
92
93 username, inbox := m.inboxForUser(userId)
94
95 for _, msg := range inbox {
96 if msg.DateSent.UnixMicro() == dateSentUs {
97 return http.StatusOK, true, toAdminEntry(userId, username, msg)
98 }
99 }
100
101 return http.StatusNotFound, false, map[string]string{"error": "message not found"}
102}
103
104// apiAdminSendMudmail handles POST /admin/api/v1/mudmail
105// Body: { "from_name": "...", "body": "...", "gold": 0, "user_id": 0 }

Callers

nothing calls this directly

Calls 2

inboxForUserMethod · 0.95
toAdminEntryFunction · 0.85

Tested by

no test coverage detected