From d870efa6660b561daa55b806c9e0835597308733 Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Mon, 8 Nov 2021 20:29:14 +0100 Subject: [PATCH] Add context support to Server.createUser --- server.go | 4 ++-- service.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/server.go b/server.go index 116a3d4..eaf6bf9 100644 --- a/server.go +++ b/server.go @@ -124,7 +124,7 @@ func (s *Server) Shutdown() { } } -func (s *Server) createUser(user *User) (*user, error) { +func (s *Server) createUser(ctx context.Context, user *User) (*user, error) { s.lock.Lock() defer s.lock.Unlock() @@ -132,7 +132,7 @@ func (s *Server) createUser(user *User) (*user, error) { return nil, fmt.Errorf("user %q already exists", user.Username) } - err := s.db.StoreUser(context.TODO(), user) + err := s.db.StoreUser(ctx, user) if err != nil { return nil, fmt.Errorf("could not create user in db: %v", err) } diff --git a/service.go b/service.go index ff5c633..4cf4150 100644 --- a/service.go +++ b/service.go @@ -758,7 +758,7 @@ func handleUserCreate(ctx context.Context, dc *downstreamConn, params []string) Realname: *realname, Admin: *admin, } - if _, err := dc.srv.createUser(user); err != nil { + if _, err := dc.srv.createUser(ctx, user); err != nil { return fmt.Errorf("could not create user: %v", err) }