38 lines
1.6 KiB
Go
38 lines
1.6 KiB
Go
package model
|
|
|
|
import (
|
|
"time"
|
|
)
|
|
|
|
// AgentBotInboxStatus represents the active/inactive state of a bot-inbox binding.
|
|
type AgentBotInboxStatus int
|
|
|
|
const (
|
|
AgentBotInboxActive AgentBotInboxStatus = 0 // Bot is actively monitoring the inbox
|
|
AgentBotInboxInactive AgentBotInboxStatus = 1 // Bot binding paused (not deleted)
|
|
)
|
|
|
|
// AgentBotInbox represents the join between AgentBot and Inbox.
|
|
// Reference: Chatwoot AgentBotInbox model + P2B M2/M12 spec
|
|
// Supports active/inactive status control — allows pausing bot monitoring without deleting binding.
|
|
// account_id is auto-populated from inbox.account_id (ensure_account_id callback).
|
|
type AgentBotInbox struct {
|
|
ID uint `gorm:"primaryKey" json:"id"`
|
|
AgentBotID uint `gorm:"not null;index;uniqueIndex:idx_agent_bot_inboxes_bot_inbox" json:"agent_bot_id"`
|
|
InboxID uint `gorm:"not null;index;uniqueIndex:idx_agent_bot_inboxes_bot_inbox" json:"inbox_id"`
|
|
AccountID *uint `gorm:"index" json:"account_id,omitempty"` // inherited from Inbox
|
|
Status AgentBotInboxStatus `gorm:"default:0" json:"status"` // 0=active, 1=inactive
|
|
CreatedAt time.Time `gorm:"autoCreateTime" json:"created_at"`
|
|
UpdatedAt time.Time `gorm:"autoUpdateTime" json:"updated_at"`
|
|
|
|
AgentBot AgentBot `gorm:"foreignKey:AgentBotID" json:"agent_bot,omitempty"`
|
|
Inbox Inbox `gorm:"foreignKey:InboxID" json:"inbox,omitempty"`
|
|
}
|
|
|
|
// IsActive returns true if the binding is in active state.
|
|
func (abi *AgentBotInbox) IsActive() bool {
|
|
return abi.Status == AgentBotInboxActive
|
|
}
|
|
|
|
func (AgentBotInbox) TableName() string { return "agent_bot_inboxes" }
|