feat(channels): add Shangwutong connector

This commit is contained in:
2026-08-03 10:13:40 +08:00
parent 96f5c796a6
commit 897b4e018f
126 changed files with 20207 additions and 272 deletions
@@ -0,0 +1,27 @@
package model
import (
"time"
"gorm.io/gorm"
)
type ChannelShangwutongConfig struct {
InboxID uint `gorm:"primaryKey" json:"inbox_id"`
SessionID string `gorm:"size:64;not null;uniqueIndex:idx_shangwutong_identity,where:deleted_at IS NULL" json:"session_id"`
Username string `gorm:"size:255;not null;uniqueIndex:idx_shangwutong_identity,where:deleted_at IS NULL" json:"username"`
Password string `gorm:"type:text;not null" json:"-"`
DesiredPresence string `gorm:"size:20;not null;default:online" json:"desired_presence"`
ConfigVersion int64 `gorm:"not null;default:1" json:"config_version"`
ActualPresence string `gorm:"size:20;not null;default:offline" json:"actual_presence"`
ConnectionStatus string `gorm:"size:40;not null;default:pending" json:"connection_status"`
CredentialStatus string `gorm:"size:40;not null;default:pending" json:"credential_status"`
LastHeartbeatAt *time.Time `json:"last_heartbeat_at,omitempty"`
LastErrorCode *string `gorm:"size:255" json:"last_error_code,omitempty"`
StatusUpdatedAt *time.Time `json:"status_updated_at,omitempty"`
CreatedAt time.Time `json:"created_at"`
UpdatedAt time.Time `json:"updated_at"`
DeletedAt gorm.DeletedAt `gorm:"index" json:"-"`
}
func (ChannelShangwutongConfig) TableName() string { return "channel_shangwutong_configs" }
+49 -47
View File
@@ -51,11 +51,11 @@ const (
type MessageType string
const (
MessageTypeIncoming MessageType = "incoming"
MessageTypeOutgoing MessageType = "outgoing"
MessageTypeActivity MessageType = "activity"
MessageTypeTemplate MessageType = "template"
MessageTypePrivate MessageType = "private"
MessageTypeIncoming MessageType = "incoming"
MessageTypeOutgoing MessageType = "outgoing"
MessageTypeActivity MessageType = "activity"
MessageTypeTemplate MessageType = "template"
MessageTypePrivate MessageType = "private"
)
type MessageContentType string
@@ -86,25 +86,26 @@ const (
type MessageStatus string
const (
MessageStatusSent MessageStatus = "sent"
MessageStatusProgress MessageStatus = "progress"
MessageStatusSent MessageStatus = "sent"
MessageStatusDelivered MessageStatus = "delivered"
MessageStatusRead MessageStatus = "read"
MessageStatusFailed MessageStatus = "failed"
MessageStatusRead MessageStatus = "read"
MessageStatusFailed MessageStatus = "failed"
)
// ConversationEventType defines domain-specific events for conversation lifecycle.
type ConversationEventType string
const (
ConversationEventCreated ConversationEventType = "created"
ConversationEventUpdated ConversationEventType = "updated"
ConversationEventStatusChanged ConversationEventType = "status_changed"
ConversationEventAssigned ConversationEventType = "assigned"
ConversationEventUnassigned ConversationEventType = "unassigned"
ConversationEventDeleted ConversationEventType = "deleted"
ConversationEventMuted ConversationEventType = "muted"
ConversationEventUnmuted ConversationEventType = "unmuted"
ConversationEventLabelsUpdated ConversationEventType = "labels_updated"
ConversationEventCreated ConversationEventType = "created"
ConversationEventUpdated ConversationEventType = "updated"
ConversationEventStatusChanged ConversationEventType = "status_changed"
ConversationEventAssigned ConversationEventType = "assigned"
ConversationEventUnassigned ConversationEventType = "unassigned"
ConversationEventDeleted ConversationEventType = "deleted"
ConversationEventMuted ConversationEventType = "muted"
ConversationEventUnmuted ConversationEventType = "unmuted"
ConversationEventLabelsUpdated ConversationEventType = "labels_updated"
ConversationEventPriorityUpdated ConversationEventType = "priority_updated"
)
@@ -123,20 +124,21 @@ const (
type InboxChannelType string
const (
InboxChannelTypeWebWidget InboxChannelType = "Channel::WebWidget"
InboxChannelTypeTelegram InboxChannelType = "Channel::Telegram"
InboxChannelTypeFacebook InboxChannelType = "Channel::FacebookPage"
InboxChannelTypeWhatsApp InboxChannelType = "Channel::Whatsapp"
InboxChannelTypeEmail InboxChannelType = "Channel::Email"
InboxChannelTypeTwilioSMS InboxChannelType = "Channel::TwilioSms"
InboxChannelTypeLine InboxChannelType = "Channel::Line"
InboxChannelTypeSMS InboxChannelType = "Channel::Sms"
InboxChannelTypeInstagram InboxChannelType = "Channel::Instagram"
InboxChannelTypeTikTok InboxChannelType = "Channel::TikTok"
InboxChannelTypeTwitter InboxChannelType = "Channel::Twitter"
InboxChannelTypeMicrosoft InboxChannelType = "Channel::Microsoft"
InboxChannelTypeGoogle InboxChannelType = "Channel::Google"
InboxChannelTypeAPI InboxChannelType = "Channel::Api"
InboxChannelTypeWebWidget InboxChannelType = "Channel::WebWidget"
InboxChannelTypeTelegram InboxChannelType = "Channel::Telegram"
InboxChannelTypeFacebook InboxChannelType = "Channel::FacebookPage"
InboxChannelTypeWhatsApp InboxChannelType = "Channel::Whatsapp"
InboxChannelTypeEmail InboxChannelType = "Channel::Email"
InboxChannelTypeTwilioSMS InboxChannelType = "Channel::TwilioSms"
InboxChannelTypeLine InboxChannelType = "Channel::Line"
InboxChannelTypeSMS InboxChannelType = "Channel::Sms"
InboxChannelTypeInstagram InboxChannelType = "Channel::Instagram"
InboxChannelTypeTikTok InboxChannelType = "Channel::TikTok"
InboxChannelTypeTwitter InboxChannelType = "Channel::Twitter"
InboxChannelTypeMicrosoft InboxChannelType = "Channel::Microsoft"
InboxChannelTypeGoogle InboxChannelType = "Channel::Google"
InboxChannelTypeAPI InboxChannelType = "Channel::Api"
InboxChannelTypeShangwutong InboxChannelType = "Channel::Shangwutong"
)
type AssignmentLogic string
@@ -159,7 +161,7 @@ const (
type ContactSource string
const (
ContactSourceChatwoot ContactSource = "chatwoot"
ContactSourceChatwoot ContactSource = "chatwoot"
ContactSourceFacebook ContactSource = "facebook"
ContactSourceWhatsApp ContactSource = "whatsapp"
ContactSourceTelegram ContactSource = "telegram"
@@ -197,12 +199,12 @@ const (
type NotificationEventType string
const (
NotificationEventConversationCreated NotificationEventType = "conversation_created"
NotificationEventConversationAssigned NotificationEventType = "conversation_assigned"
NotificationEventMessageCreated NotificationEventType = "message_created"
NotificationEventConversationCreated NotificationEventType = "conversation_created"
NotificationEventConversationAssigned NotificationEventType = "conversation_assigned"
NotificationEventMessageCreated NotificationEventType = "message_created"
NotificationEventConversationStatusChanged NotificationEventType = "conversation_status_changed"
NotificationEventAssigneeChanged NotificationEventType = "assignee_changed"
NotificationEventTeamChanged NotificationEventType = "team_changed"
NotificationEventAssigneeChanged NotificationEventType = "assignee_changed"
NotificationEventTeamChanged NotificationEventType = "team_changed"
)
type SubscriptionType string
@@ -309,7 +311,7 @@ type AttributeModelType string
const (
AttributeModelConversation AttributeModelType = "conversation"
AttributeModelContact AttributeModelType = "contact"
AttributeModelContact AttributeModelType = "contact"
)
type AttributeValueType string
@@ -328,9 +330,9 @@ type FilterType string
const (
FilterTypeConversation FilterType = "conversation"
FilterTypeContact FilterType = "contact"
FilterTypeInbox FilterType = "inbox"
FilterTypeMessage FilterType = "message"
FilterTypeContact FilterType = "contact"
FilterTypeInbox FilterType = "inbox"
FilterTypeMessage FilterType = "message"
)
// --- Reporting Enums (M7) ---
@@ -359,11 +361,11 @@ const (
HookTypeInboxOutgoing HookType = "inbox_outgoing"
HookTypeAccountOutgoing HookType = "account_outgoing"
// M11: Integration hook types (webhook/slack/shopify/linear/notion)
HookTypeWebhook HookType = "webhook"
HookTypeSlack HookType = "slack"
HookTypeShopify HookType = "shopify"
HookTypeLinear HookType = "linear"
HookTypeNotion HookType = "notion"
HookTypeWebhook HookType = "webhook"
HookTypeSlack HookType = "slack"
HookTypeShopify HookType = "shopify"
HookTypeLinear HookType = "linear"
HookTypeNotion HookType = "notion"
)
type HookStatus string
@@ -390,4 +392,4 @@ type TwilioMedium string
const (
TwilioMediumSMS TwilioMedium = "sms"
TwilioMediumWhatsApp TwilioMedium = "whatsapp"
)
)
+5 -3
View File
@@ -9,20 +9,22 @@ 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"`
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"` // sent, delivered, read, failed
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" json:"source_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"`
Conversation *Conversation `gorm:"foreignKey:ConversationID" json:"conversation,omitempty"`
Attachments []Attachment `gorm:"foreignKey:MessageID" json:"attachments,omitempty"`