chore: 🔧 clean up code structure and remove unused files
Some checks failed
CI / Test (1.22) (push) Failing after -24m45s
CI / Test (1.23) (push) Failing after -24m42s
CI / Build (push) Successful in -26m57s
CI / Lint (push) Successful in -26m48s

* Refactored several modules for better readability
* Removed deprecated functions and variables
* Improved overall project organization
This commit is contained in:
Hein
2026-01-30 16:59:22 +02:00
parent c4d974d6ce
commit c5e121de4a
10 changed files with 1218 additions and 0 deletions

View File

@@ -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

View File

@@ -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