Files
gochat/internal/model/message.go
T
2026-06-04 15:44:48 +08:00

27 lines
1.6 KiB
Go

package model
import (
"gorm.io/datatypes"
)
// Message represents a message within a conversation.
type Message struct {
Base
ConversationID uint `gorm:"index;not null" json:"conversation_id"`
AccountID uint `gorm:"index;not null" json:"account_id"`
InboxID uint `gorm:"index;not null" json:"inbox_id"`
SenderID *uint `gorm:"index" json:"sender_id,omitempty"`
SenderType string `gorm:"size:50" json:"sender_type"` // contact, agent, bot
Content string `gorm:"type:text" json:"content"`
ContentType string `gorm:"size:50;default:text" json:"content_type"` // text, input, input_csat, file, image, etc
Status string `gorm:"size:50;default:sent" json:"status"` // sent, delivered, read, failed
Private bool `gorm:"default:false" json:"private"`
SourceID string `gorm:"size:255" json:"source_id,omitempty"`
MessageType string `gorm:"size:50;default:incoming" json:"message_type"` // incoming, outgoing, activity, template
External bool `gorm:"default:false" json:"external"`
ContentAttributes datatypes.JSON `gorm:"type:jsonb" json:"content_attributes,omitempty"` // attachments, mentions, etc
AdditionalAttributes datatypes.JSON `gorm:"type:jsonb" json:"additional_attributes,omitempty"`
ExternalSourceIDs datatypes.JSON `gorm:"type:jsonb" json:"external_source_ids,omitempty"` // external platform IDs
}
func (Message) TableName() string { return "messages" }