refactor(signserver): replace raw SQL with repository interfaces

Extract all direct database access into three repository interfaces
(SignUserRepo, SignCharacterRepo, SignSessionRepo) matching the
pattern established in channelserver. This surfaces 9 previously
silenced errors that are now logged with structured context, and
makes the sign server testable with mock repos instead of go-sqlmock.

Security fix: GetFriends now uses parameterized ANY($1) queries
instead of string-concatenated WHERE clauses (SQL injection vector).
This commit is contained in:
Houmgaor
2026-02-22 16:30:24 +01:00
parent 53b5bb3b96
commit b3f75232a3
11 changed files with 1193 additions and 435 deletions

View File

@@ -24,7 +24,9 @@ type Server struct {
sync.Mutex
logger *zap.Logger
erupeConfig *cfg.Config
db *sqlx.DB
userRepo SignUserRepo
charRepo SignCharacterRepo
sessionRepo SignSessionRepo
listener net.Listener
isShuttingDown bool
}
@@ -34,7 +36,11 @@ func NewServer(config *Config) *Server {
s := &Server{
logger: config.Logger,
erupeConfig: config.ErupeConfig,
db: config.DB,
}
if config.DB != nil {
s.userRepo = NewSignUserRepository(config.DB)
s.charRepo = NewSignCharacterRepository(config.DB)
s.sessionRepo = NewSignSessionRepository(config.DB)
}
return s
}