Files
gochat/backend/internal/model/message.go
T
Rogeeandrogee 83a8ab315a H-16: align takeover with channel AI workflow (#2)
* feat(conversations): complete manual AI takeover

* fix(conversations): align AI takeover flow with channel AI

* fix(conversations): close takeover review gaps

---------

Co-authored-by: Rogee <rogee@ipao.vip>
2026-08-12 22:57:06 +08:00

35 lines
2.2 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;uniqueIndex:idx_messages_swt_source,priority:1,where:source_id LIKE 'swt:%'" 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"` // progress, 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;uniqueIndex:idx_messages_swt_source,priority:2,where:source_id LIKE 'swt:%'" 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
ExternalRequestHash string `gorm:"size:64" json:"-"`
IdempotentReplay bool `gorm:"-" json:"idempotent_replay,omitempty"`
AITakeoverExited bool `gorm:"-" json:"ai_takeover_exited,omitempty"`
Conversation *Conversation `gorm:"foreignKey:ConversationID" json:"conversation,omitempty"`
Attachments []Attachment `gorm:"foreignKey:MessageID" json:"attachments,omitempty"`
}
func (Message) TableName() string { return "messages" }