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

Method SendMudMail

modules/mudmail/mudmail.go:187–210  ·  view source on GitHub ↗

SendMudMail is exported for use by other modules. Signature: func(userId int, fromName string, message string, gold int, itm *items.Item)

(userId int, fromName string, message string, gold int, itm *items.Item)

Source from the content-addressed store, hash-verified

185// SendMudMail is exported for use by other modules.
186// Signature: func(userId int, fromName string, message string, gold int, itm *items.Item)
187func (m *MudmailModule) SendMudMail(userId int, fromName string, message string, gold int, itm *items.Item) {
188 msg := Message{
189 FromName: fromName,
190 Body: message,
191 Gold: gold,
192 Item: itm,
193 DateSent: time.Now(),
194 }
195
196 // Online: update in-memory inbox and notify.
197 if u := users.GetByUserId(userId); u != nil {
198 inbox := m.inboxes[userId]
199 inbox = append(Inbox{msg}, inbox...)
200 m.inboxes[userId] = inbox
201 m.save(userId, inbox)
202 u.Command(`inbox check`)
203 return
204 }
205
206 // Offline: read from disk, append, write back.
207 inbox := m.load(userId)
208 inbox = append(Inbox{msg}, inbox...)
209 m.save(userId, inbox)
210}
211
212// Inbox management helpers.
213

Callers 1

apiAdminSendMudmailMethod · 0.95

Calls 4

saveMethod · 0.95
loadMethod · 0.95
GetByUserIdFunction · 0.92
CommandMethod · 0.45

Tested by

no test coverage detected