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

Method inboxForUser

modules/mudmail/admin.go:233–243  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
233func (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).
246func toSummaryEntry(userId int, username string, msg Message) adminSummaryEntry {

Callers 2

apiAdminListMudmailMethod · 0.95

Calls 4

loadMethod · 0.95
GetByUserIdFunction · 0.92
GetUserIndexFunction · 0.92
FindByUserIdMethod · 0.80

Tested by

no test coverage detected