finish setup data insertion, add world insertion

This commit is contained in:
lbenedar
2026-04-22 18:18:43 +03:00
parent 21abe68858
commit f46ff8333e
66 changed files with 2257 additions and 676 deletions

View File

@@ -21,27 +21,33 @@ type Message struct {
// Flags any `json:"flags"`
}
func (m *Message) ToDB(dest *db.Message) bool {
func (m *Message) ToDB(dest **db.Message) bool {
if dest == nil {
return false
}
dest.Content = m.Content
dest.Style = m.Style
dest.Author = m.Author
dest.ID = m.Id
dest.Type = m.Type
dest.Timestamp = m.Timestamp
dest.Flavor = m.Flavor
dest.Blind = m.Blind
dest.Sound = m.Sound
dest.Emote = m.Emote
message := &db.Message{
Content: m.Content,
Style: m.Style,
Author: m.Author,
ID: m.Id,
Type: m.Type,
Timestamp: m.Timestamp,
Flavor: m.Flavor,
Blind: m.Blind,
Sound: m.Sound,
Emote: m.Emote,
}
m.Speaker.ToDB(&dest.Speaker)
m.Stats.ToDB(&dest.Stats)
m.Speaker.ToDB(&message.Speaker)
m.Stats.ToDB(&message.Stats)
copy(dest.Whisper, m.Whisper)
copy(dest.Rolls, m.Rolls)
message.Whisper = make([]string, len(m.Whisper))
copy(message.Whisper, m.Whisper)
message.Rolls = make([]string, len(m.Rolls))
copy(message.Rolls, m.Rolls)
*dest = message
return true
}