messaging-center/internal/api/channels.go

46 lines
1.2 KiB
Go

package api
import (
"net/http"
"github.com/inou-ai/messaging-center/internal/core"
)
// ChannelsResponse wraps a list of channels for API response.
type ChannelsResponse struct {
Channels []core.Channel `json:"channels"`
}
// handleListChannels handles GET /api/v1/channels (stub).
func (s *Server) handleListChannels(w http.ResponseWriter, r *http.Request) {
// For now, return configured channels with unknown status
// Actual status will come from adapters once implemented
var channels []core.Channel
if s.config.Channels.Email != nil && s.config.Channels.Email.Enabled {
channels = append(channels, core.Channel{
Name: "email",
Enabled: true,
Status: "not_implemented",
})
}
if s.config.Channels.WhatsApp != nil && s.config.Channels.WhatsApp.Enabled {
channels = append(channels, core.Channel{
Name: "whatsapp",
Enabled: true,
Status: "not_implemented",
})
}
if s.config.Channels.Signal != nil && s.config.Channels.Signal.Enabled {
channels = append(channels, core.Channel{
Name: "signal",
Enabled: true,
Status: "not_implemented",
})
}
writeJSON(w, http.StatusOK, ChannelsResponse{Channels: channels})
}