Changeset 0.20.0 (#85)
This commit is contained in:
@@ -21,6 +21,7 @@ import (
|
||||
"git.gobha.me/xcaliber/chat-switchboard/knowledge"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/memory"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/middleware"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/notifications"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/providers"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/roles"
|
||||
"git.gobha.me/xcaliber/chat-switchboard/storage"
|
||||
@@ -185,6 +186,35 @@ func main() {
|
||||
// ── WebSocket Hub ─────────────────────────
|
||||
hub := events.NewHub(bus)
|
||||
|
||||
// ── Notification Service (v0.20.0) ───────
|
||||
var notifSvc *notifications.Service
|
||||
if stores.Notifications != nil {
|
||||
notifSvc = notifications.NewService(stores.Notifications, hub).
|
||||
WithPrefs(stores.NotifPrefs).
|
||||
WithUsers(stores.Users)
|
||||
|
||||
// Load SMTP config from platform settings for email transport (Phase 3)
|
||||
if stores.GlobalConfig != nil {
|
||||
if smtpCfg, err := notifications.LoadSMTPConfig(stores.GlobalConfig, keyResolver); err == nil && smtpCfg != nil {
|
||||
transport := notifications.NewEmailTransport(*smtpCfg)
|
||||
instanceName := "Chat Switchboard"
|
||||
if brandCfg, err := stores.GlobalConfig.Get(context.Background(), "branding"); err == nil {
|
||||
if name, ok := brandCfg["instance_name"].(string); ok && name != "" {
|
||||
instanceName = name
|
||||
}
|
||||
}
|
||||
notifSvc.WithEmail(transport, instanceName)
|
||||
log.Println("[notifications] email transport enabled")
|
||||
}
|
||||
}
|
||||
notifSvc.StartCleanup()
|
||||
notifications.SetDefault(notifSvc)
|
||||
|
||||
// Subscribe to role.fallback events → generate notifications for admins
|
||||
bus.Subscribe("role.fallback", notifications.RoleFallbackHandler(notifSvc, stores))
|
||||
defer notifSvc.StopCleanup()
|
||||
}
|
||||
|
||||
// Health check (k8s probes hit this directly)
|
||||
base.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
@@ -246,6 +276,13 @@ func main() {
|
||||
protected.PUT("/channels/:id", channels.UpdateChannel)
|
||||
protected.DELETE("/channels/:id", channels.DeleteChannel)
|
||||
|
||||
// Channel models (v0.20.0 — multi-model @mention routing)
|
||||
chModelH := handlers.NewChannelModelHandler(stores)
|
||||
protected.GET("/channels/:id/models", chModelH.List)
|
||||
protected.POST("/channels/:id/models", chModelH.Add)
|
||||
protected.PATCH("/channels/:id/models/:modelId", chModelH.Update)
|
||||
protected.DELETE("/channels/:id/models/:modelId", chModelH.Delete)
|
||||
|
||||
// Messages
|
||||
msgs := handlers.NewMessageHandler(keyResolver, stores, hub, objStore)
|
||||
protected.GET("/channels/:id/messages", msgs.ListMessages)
|
||||
@@ -350,6 +387,19 @@ func main() {
|
||||
protected.DELETE("/projects/:id/notes/:noteId", projectH.RemoveNote)
|
||||
protected.GET("/projects/:id/notes", projectH.ListNotes)
|
||||
|
||||
// Notifications (v0.20.0)
|
||||
notifH := handlers.NewNotificationHandler(stores, hub)
|
||||
protected.GET("/notifications", notifH.List)
|
||||
protected.GET("/notifications/unread-count", notifH.UnreadCount)
|
||||
protected.PATCH("/notifications/:id/read", notifH.MarkRead)
|
||||
protected.POST("/notifications/mark-all-read", notifH.MarkAllRead)
|
||||
protected.DELETE("/notifications/:id", notifH.Delete)
|
||||
|
||||
// Notification preferences (v0.20.0 Phase 3)
|
||||
protected.GET("/notifications/preferences", notifH.ListPreferences)
|
||||
protected.PUT("/notifications/preferences/:type", notifH.SetPreference)
|
||||
protected.DELETE("/notifications/preferences/:type", notifH.DeletePreference)
|
||||
|
||||
// Attachments (file upload/download)
|
||||
attachH := handlers.NewAttachmentHandler(stores, objStore, extQueue)
|
||||
protected.POST("/channels/:id/attachments", attachH.Upload)
|
||||
@@ -563,6 +613,10 @@ func main() {
|
||||
// Vault
|
||||
admin.GET("/vault/status", adm.VaultStatus)
|
||||
|
||||
// Email / SMTP test (v0.20.0 Phase 3)
|
||||
emailAdm := handlers.NewAdminEmailHandler(stores)
|
||||
admin.POST("/notifications/test-email", emailAdm.TestEmail)
|
||||
|
||||
// Storage management (orphan cleanup)
|
||||
attachAdm := handlers.NewAttachmentHandler(stores, objStore, extQueue)
|
||||
admin.GET("/storage/orphans", attachAdm.OrphanCount)
|
||||
|
||||
Reference in New Issue
Block a user