Private
Public Access
1
0
Files
Kordophone/mock/model/message.go

36 lines
824 B
Go
Raw Permalink Normal View History

2023-06-19 18:31:05 -07:00
package model
2023-06-23 00:44:25 -07:00
import (
2024-01-05 16:26:19 -08:00
"time"
"github.com/rs/zerolog"
2023-06-23 00:44:25 -07:00
)
2023-06-19 18:31:05 -07:00
type Message struct {
2024-01-05 16:26:19 -08:00
Text string `json:"text"`
Guid string `json:"guid"`
Sender *string `json:"sender,omitempty"` // Optional: nil means from "me"
Date Date `json:"date"`
2023-06-19 18:31:05 -07:00
// Map of attachment GUID to attachment metadata
AttachmentGUIDs []string `json:"fileTransferGUIDs,omitempty"`
AttachmentMetadata *map[string]AttributionInfo `json:"attachmentMetadata,omitempty"` // Optional
2023-06-19 18:31:05 -07:00
}
type AttributionInfo struct {
ThumbnailWidth int `json:"pgensw"`
ThumbnailHeight int `json:"pgensh"`
}
2023-06-23 00:44:25 -07:00
func (c Message) MarshalZerologObject(e *zerolog.Event) {
e.Str("guid", c.Guid)
e.Str("text", c.Text)
2024-01-05 16:26:19 -08:00
e.Time("date", time.Time(c.Date))
2023-06-23 00:44:25 -07:00
if c.Sender != nil {
e.Str("sender", *c.Sender)
} else {
e.Str("sender", "(Me)")
}
}