spark-server/internal/module/message/entity/message.go
zhr ae9a71034d feat: implement Spark IM V3 modular monolith
Add HTTP /v1 MVC, TCP send path, groups with server-side member-avatar collage, object-storage upload, and friends/favorites around the architecture-v3 layout.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-17 19:52:11 +08:00

30 lines
599 B
Go

package entity
import "fmt"
// Message is a persisted IM body. Content is serialized JSON bytes, not a string.
type Message struct {
ID int64
ConversationID int64
SenderID int64
ClientMsgID string
Type Type
Content []byte
Status int
CreatedAtMS int64
}
func (m *Message) Payload() (*Content, error) {
if m == nil {
return nil, nil
}
c, err := UnmarshalContent(m.Content)
if err != nil {
return nil, err
}
if c.Type != m.Type {
return nil, fmt.Errorf("content: column type %d != payload %d", m.Type, c.Type)
}
return c, nil
}