chore: 🔧 clean up code structure and remove unused files
* Refactored several modules for better readability * Removed deprecated functions and variables * Improved overall project organization
This commit is contained in:
@@ -204,6 +204,12 @@ func (s *Server) setupRoutes() *http.ServeMux {
|
||||
mux := http.NewServeMux()
|
||||
h := s.wh.Handlers()
|
||||
|
||||
// Landing page (no auth required)
|
||||
mux.HandleFunc("/", h.ServeIndex)
|
||||
|
||||
// Static files (no auth required)
|
||||
mux.HandleFunc("/static/", h.ServeStatic)
|
||||
|
||||
// Health check (no auth required)
|
||||
mux.HandleFunc("/health", h.Health)
|
||||
|
||||
@@ -215,7 +221,10 @@ func (s *Server) setupRoutes() *http.ServeMux {
|
||||
// Account management (with auth)
|
||||
mux.HandleFunc("/api/accounts", h.Auth(h.Accounts))
|
||||
mux.HandleFunc("/api/accounts/add", h.Auth(h.AddAccount))
|
||||
mux.HandleFunc("/api/accounts/update", h.Auth(h.UpdateAccount))
|
||||
mux.HandleFunc("/api/accounts/remove", h.Auth(h.RemoveAccount))
|
||||
mux.HandleFunc("/api/accounts/disable", h.Auth(h.DisableAccount))
|
||||
mux.HandleFunc("/api/accounts/enable", h.Auth(h.EnableAccount))
|
||||
|
||||
// Send messages (with auth)
|
||||
mux.HandleFunc("/api/send", h.Auth(h.SendMessage))
|
||||
@@ -242,11 +251,14 @@ func (s *Server) setupRoutes() *http.ServeMux {
|
||||
mux.HandleFunc("/api/cache/clear", h.Auth(h.ClearCache)) // DELETE with ?confirm=true
|
||||
|
||||
logging.Info("HTTP server endpoints configured",
|
||||
"index", "/",
|
||||
"static", "/static/*",
|
||||
"health", "/health",
|
||||
"hooks", "/api/hooks",
|
||||
"accounts", "/api/accounts",
|
||||
"send", "/api/send",
|
||||
"cache", "/api/cache",
|
||||
"webhooks", "/webhooks/whatsapp/*",
|
||||
"qr", "/api/qr")
|
||||
|
||||
return mux
|
||||
|
||||
@@ -131,6 +131,12 @@ func newWithConfig(cfg *config.Config, configPath string) (*WhatsHooked, error)
|
||||
// ConnectAll connects to all configured WhatsApp accounts
|
||||
func (wh *WhatsHooked) ConnectAll(ctx context.Context) error {
|
||||
for _, waCfg := range wh.config.WhatsApp {
|
||||
// Skip disabled accounts
|
||||
if waCfg.Disabled {
|
||||
logging.Info("Skipping disabled account", "account_id", waCfg.ID)
|
||||
continue
|
||||
}
|
||||
|
||||
if err := wh.whatsappMgr.Connect(ctx, waCfg); err != nil {
|
||||
logging.Error("Failed to connect to WhatsApp", "account_id", waCfg.ID, "error", err)
|
||||
// Continue connecting to other accounts even if one fails
|
||||
|
||||
Reference in New Issue
Block a user