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)
| 78 | // Returns the full message data for a single message identified by user_id and |
| 79 | // unix timestamp. |
| 80 | func (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 } |
nothing calls this directly
no test coverage detected