refactor: migrate HTTP handlers to shared service layer
All checks were successful
check / check (push) Successful in 54s
All checks were successful
check / check (push) Successful in 54s
- Migrate all HTTP command handlers (PRIVMSG, JOIN, PART, NICK, TOPIC, KICK, QUIT, AWAY, OPER, MODE) to use hdlr.svc.* service methods instead of direct database calls. Both HTTP and IRC transports now share the same business logic path. - Fix BroadcastQuit bug: was inserting N separate message rows (one per recipient); now uses FanOut pattern with 1 InsertMessage + N EnqueueToSession calls. - Fix README: IRC listener is enabled by default on :6667, not disabled. Remove redundant -e IRC_LISTEN_ADDR from Docker example. - Add EXPOSE 6667 to Dockerfile alongside existing HTTP port. - Add service layer unit tests (JoinChannel, PartChannel, SendChannelMessage, FanOut, BroadcastQuit, moderated channel). - Update handler test setup to provide Service instance. - Use constant-time comparison in Oper credential validation to prevent timing attacks. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -28,6 +28,7 @@ import (
|
||||
"git.eeqj.de/sneak/neoirc/internal/logger"
|
||||
"git.eeqj.de/sneak/neoirc/internal/middleware"
|
||||
"git.eeqj.de/sneak/neoirc/internal/server"
|
||||
"git.eeqj.de/sneak/neoirc/internal/service"
|
||||
"git.eeqj.de/sneak/neoirc/internal/stats"
|
||||
"go.uber.org/fx"
|
||||
"go.uber.org/fx/fxtest"
|
||||
@@ -207,6 +208,14 @@ func newTestHandlers(
|
||||
hcheck *healthcheck.Healthcheck,
|
||||
tracker *stats.Tracker,
|
||||
) (*handlers.Handlers, error) {
|
||||
brk := broker.New()
|
||||
svc := service.New(service.Params{ //nolint:exhaustruct
|
||||
Logger: log,
|
||||
Config: cfg,
|
||||
Database: database,
|
||||
Broker: brk,
|
||||
})
|
||||
|
||||
hdlr, err := handlers.New(lifecycle, handlers.Params{ //nolint:exhaustruct
|
||||
Logger: log,
|
||||
Globals: globs,
|
||||
@@ -214,7 +223,8 @@ func newTestHandlers(
|
||||
Database: database,
|
||||
Healthcheck: hcheck,
|
||||
Stats: tracker,
|
||||
Broker: broker.New(),
|
||||
Broker: brk,
|
||||
Service: svc,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("test handlers: %w", err)
|
||||
|
||||
Reference in New Issue
Block a user