inboxForUser returns the username and inbox for a given userId, preferring the in-memory copy for online users and falling back to disk for offline ones.
(userId int)
| 231 | // inboxForUser returns the username and inbox for a given userId, preferring |
| 232 | // the in-memory copy for online users and falling back to disk for offline ones. |
| 233 | func (m *MudmailModule) inboxForUser(userId int) (username string, inbox Inbox) { |
| 234 | if u := users.GetByUserId(userId); u != nil { |
| 235 | return u.Username, m.inboxes[userId] |
| 236 | } |
| 237 | // Offline: find username from index then load from disk. |
| 238 | idx := users.GetUserIndex() |
| 239 | if name, ok := idx.FindByUserId(userId); ok { |
| 240 | username = name |
| 241 | } |
| 242 | return username, m.load(userId) |
| 243 | } |
| 244 | |
| 245 | // toSummaryEntry converts a Message into the summary shape (no body). |
| 246 | func toSummaryEntry(userId int, username string, msg Message) adminSummaryEntry { |
no test coverage detected