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
@@ -128,6 +128,10 @@ type chatwootMessagePayload struct {
CreatedAt int64 `json:"created_at"`
Private bool `json:"private"`
SourceID string `json:"source_id"`
External bool `json:"external"`
ExternalSourceIDs map[string]any `json:"external_source_ids"`
AdditionalAttrs map[string]any `json:"additional_attributes"`
IdempotentReplay bool `json:"idempotent_replay,omitempty"`
Sender map[string]any `json:"sender,omitempty"`
Attachments []any `json:"attachments,omitempty"`
Call map[string]any `json:"call,omitempty"`
@@ -438,6 +442,10 @@ func serializeMessage(ctx context.Context, db *gorm.DB, message *model.Message,
CreatedAt: message.CreatedAt.Unix(),
Private: message.Private,
SourceID: message.SourceID,
External: message.External,
ExternalSourceIDs: jsonObject(message.ExternalSourceIDs),
AdditionalAttrs: jsonObject(message.AdditionalAttributes),
IdempotentReplay: message.IdempotentReplay,
}
if db != nil && message.SenderID != nil && *message.SenderID != 0 {
senderType := normalizedSenderType(message.SenderType)
@@ -606,7 +614,7 @@ func serializeAttachment(ctx context.Context, db *gorm.DB, attachment *model.Att
func serializeAttachmentPushEventData(attachment *model.Attachment) map[string]any {
extension := strings.TrimPrefix(filepath.Ext(attachment.FileName), ".")
dataURL := nonEmpty(attachment.FileURL, attachment.ExternalURL)
return map[string]any{
payload := map[string]any{
"id": attachment.ID,
"message_id": attachment.MessageID,
"file_type": attachment.FileType,
@@ -618,6 +626,13 @@ func serializeAttachmentPushEventData(attachment *model.Attachment) map[string]a
"width": attachment.Width,
"height": attachment.Height,
}
if strings.TrimSpace(attachment.Metadata) != "" {
metadata := map[string]any{}
if json.Unmarshal([]byte(attachment.Metadata), &metadata) == nil {
payload["metadata"] = metadata
}
}
return payload
}
func serializeAttachmentWithConversation(ctx context.Context, db *gorm.DB, attachment *model.Attachment) map[string]any {