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
+1
View File
@@ -254,6 +254,7 @@ func autoMigrate(db *gorm.DB) error {
&model.CaptainMessageReport{},
// S6: WorkingHour — out-of-office / business hours per inbox
&model.WorkingHour{},
&model.ChannelShangwutongConfig{},
// Notification settings — per-user per-account notification preferences
&model.NotificationSetting{},
}
+6 -3
View File
@@ -375,6 +375,7 @@ func Bootstrap(env string) (*App, error) {
channelDispatcher.Register(fbListener)
channelDispatcher.Register(igListener)
channelDispatcher.Register(channel.NewWebhookListenerWithDB(db))
channelDispatcher.Register(service.NewShangwutongTypingWebhookListener(db))
// Create Facebook webhook handler (Gin HTTP handler for FB/IG webhook endpoints)
facebookWebhookHandler := webhook.NewFacebookWebhookHandler(fbProvider, igProvider, db, channelDispatcher)
facebookWebhookHandler.WithWorkerPool(workerPool)
@@ -488,6 +489,7 @@ func Bootstrap(env string) (*App, error) {
inboxService := service.NewInboxService(inboxRepo, agentBotInboxRepo, agentBotRepo, campaignRepo, webhookSubRepo, waService, waRepo)
inboxService.SetWorkerPool(workerPool)
service.RegisterInboxTemplateSyncJobs(workerPool, inboxService)
service.RegisterShangwutongWebhookDeliveryJobs(workerPool, db, channelDispatcher)
igRepo := repository.NewChannelInstagramRepo(db)
igService := service.NewChannelInstagramService(igRepo, igProvider)
fbChannelRepo := repository.NewChannelFacebookRepo(db)
@@ -855,7 +857,7 @@ func Bootstrap(env string) (*App, error) {
Search: v1.NewSearchHandler(searchService, db),
Widget: widgetHandler,
// M13: SSO enterprise authentication handlers
SSOSession: v1.NewSSOSessionHandler(ssoSessionStore),
SSOSession: v1.NewSSOSessionHandler(ssoSessionStore),
// M13: OIDC enterprise authentication handlers
OIDC: v1.NewOIDCHandler(oidcService, ssoMiddleware, jwtService, refreshStore, &cfg.OIDC),
SSOMiddleware: ssoMiddleware,
@@ -909,7 +911,8 @@ func Bootstrap(env string) (*App, error) {
// EmailChannelMigration handler (account-scoped create-only)
EmailChannelMigration: v1.NewEmailChannelMigrationHandler(emailChannelMigrationService),
// SummaryReport handler (read-only reporting resource — agent/team/inbox/label summaries)
SummaryReport: v1.NewSummaryReportHandler(summaryReportService),
SummaryReport: v1.NewSummaryReportHandler(summaryReportService),
ShangwutongConnector: v1.NewShangwutongConnectorHandler(db, messageService),
}
// Step 10: Setup Gin router + middleware chain
// (ref: Chatwoot Rails middleware stack in config/application.rb)
@@ -920,7 +923,7 @@ func Bootstrap(env string) (*App, error) {
corsMiddleware := middleware.CORS(middleware.CORSConfigFromAppConfig(cfg))
engine.Use(middleware.Recovery()) // panic recovery
engine.Use(middleware.RequestLogger()) // structured request logging
engine.Use(middleware.RateLimit(rdb)) // rate limiting (ref: Chatwoot rack-attack)
engine.Use(middleware.RateLimit(rdb)) // rate limiting (ref: Chatwoot rack-attack)
engine.Use(corsMiddleware) // CORS with configurable whitelist
engine.Use(middleware.SecurityHeaders(middleware.DefaultSecurityHeadersConfig())) // security headers (ref: P14 deliverable #11)
engine.StaticFS("/uploads", gin.Dir(cfg.Storage.LocalPath, false))