feat(conversations): align chatwoot message serializers

This commit is contained in:
2026-06-05 01:52:07 +08:00
parent c964d6c8fd
commit 9f89cbfe7c
12 changed files with 908 additions and 208 deletions
+16 -15
View File
@@ -7,21 +7,22 @@ import (
// 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
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"`
EchoID string `gorm:"size:255" json:"echo_id,omitempty"`
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
ExternalSourceIDs datatypes.JSON `gorm:"type:jsonb" json:"external_source_ids,omitempty"` // external platform IDs
}
func (Message) TableName() string { return "messages" }
func (Message) TableName() string { return "messages" }