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 }