Files
gochat/internal/model/conversation_participant.go
T

20 lines
1.0 KiB
Go

package model
// ConversationParticipant represents a participant (user) in a conversation.
// Reference: Chatwoot app/models/conversation_participant.rb
// Unique index: (user_id, conversation_id)
// Validates: account_id presence, inbox access via assignable_agents
type ConversationParticipant struct {
Base
AccountID uint `gorm:"index;not null" json:"account_id"`
ConversationID uint `gorm:"index;uniqueIndex:idx_conv_participants_user_conv;not null" json:"conversation_id"`
UserID uint `gorm:"index;uniqueIndex:idx_conv_participants_user_conv;not null" json:"user_id"`
Role string `gorm:"size:50;default:participant" json:"role"` // participant, assignee, watcher
Account *Account `gorm:"foreignKey:AccountID" json:"account,omitempty"`
Conversation *Conversation `gorm:"foreignKey:ConversationID" json:"conversation,omitempty"`
User *User `gorm:"foreignKey:UserID" json:"user,omitempty"`
}
func (ConversationParticipant) TableName() string { return "conversation_participants" }