Fix correctness bugs found by code review
- matrix: drop cryptohelper LoginAs so device.json creds aren't invalidated on every restart by Init's re-login - matrix: thread ctx through PostThreadedReply; bot dispatcher derives per-command ctx from app lifecycle so SIGTERM cancels in-flight work - matrix: isTokenValid verifies /whoami user_id matches configured one - matrix: loadDevice distinguishes missing file from corrupt parse; refuse to silently overwrite a corrupt device.json - matrix: Start checks Syncer type assertion and returns error - arr: parseLookup skips empty-title items and extracts existing id - bot: skip Add when Result.Exists; reply "already in library"
This commit is contained in:
12
main.go
12
main.go
@@ -43,13 +43,17 @@ func main() {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
dispatcher := bot.New(cfg.Matrix.CommandPrefix, services, mx)
|
||||
mx.SetMessageHandler(dispatcher.Handle)
|
||||
|
||||
ctx, cancel := context.WithCancel(context.Background())
|
||||
defer cancel()
|
||||
|
||||
mx.Start(ctx)
|
||||
dispatcher := bot.New(ctx, cfg.Matrix.CommandPrefix, services, mx)
|
||||
mx.SetMessageHandler(dispatcher.Handle)
|
||||
|
||||
if err := mx.Start(ctx); err != nil {
|
||||
slog.Error("matrix start failed", "err", err)
|
||||
mx.Stop()
|
||||
os.Exit(1)
|
||||
}
|
||||
slog.Info("bellhop started", "allowed_rooms", len(cfg.Matrix.AllowedRooms))
|
||||
|
||||
sig := make(chan os.Signal, 1)
|
||||
|
||||
Reference in New Issue
Block a user