68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
package json
|
|
|
|
import "gitea.local.lab/Lbenedar/foundry_helper_service/internal/foundry/temp_models/db"
|
|
|
|
type Message struct {
|
|
Content string `json:"content"`
|
|
Style int `json:"style"`
|
|
Author string `json:"author"`
|
|
Id string `json:"_id"`
|
|
Type string `json:"type"`
|
|
Timestamp int64 `json:"timestamp"`
|
|
Flavor string `json:"flavor"`
|
|
Speaker Speaker `json:"speaker"`
|
|
Whisper []string `json:"whisper"`
|
|
Blind bool `json:"blind"`
|
|
Rolls []string `json:"rolls"`
|
|
Sound string `json:"sound"`
|
|
Emote bool `json:"emote"`
|
|
Stats Stats `json:"_stats"`
|
|
// System any `json:"system"`
|
|
// Flags any `json:"flags"`
|
|
}
|
|
|
|
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
|
|
|
|
m.Speaker.ToDB(&dest.Speaker)
|
|
m.Stats.ToDB(&dest.Stats)
|
|
|
|
copy(dest.Whisper, m.Whisper)
|
|
copy(dest.Rolls, m.Rolls)
|
|
|
|
return true
|
|
}
|
|
|
|
type Speaker struct {
|
|
Scene string `json:"scene,omitempty"`
|
|
Actor string `json:"actor,omitempty"`
|
|
Token string `json:"token,omitempty"`
|
|
Alias string `json:"alias,omitempty"`
|
|
}
|
|
|
|
func (s *Speaker) ToDB(dest *db.Speaker) bool {
|
|
if dest == nil {
|
|
return false
|
|
}
|
|
|
|
dest.Scene = s.Scene
|
|
dest.Actor = s.Actor
|
|
dest.Token = s.Token
|
|
dest.Alias = s.Alias
|
|
|
|
return true
|
|
}
|