From 3f4b0b555435d218e67aad16caad26a993fc70c6 Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Mon, 1 Jun 2020 13:59:42 +0200 Subject: [PATCH] Rename variable --- appservice/appservice.go | 2 +- clientapi/auth/storage/accounts/postgres/storage.go | 2 +- clientapi/routing/register.go | 2 +- internal/sql.go | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appservice/appservice.go b/appservice/appservice.go index d78741983..68cf52e79 100644 --- a/appservice/appservice.go +++ b/appservice/appservice.go @@ -121,7 +121,7 @@ func generateAppServiceAccount( // Create an account for the application service _, err := accountsDB.CreateAccount(ctx, as.SenderLocalpart, "", as.ID) if err != nil { - if errors.Is(err, internal.ErrSQLUserExists) { // This account already exists + if errors.Is(err, internal.ErrUserExists) { // This account already exists return nil } return err diff --git a/clientapi/auth/storage/accounts/postgres/storage.go b/clientapi/auth/storage/accounts/postgres/storage.go index ba52ecfdc..d7a753fb6 100644 --- a/clientapi/auth/storage/accounts/postgres/storage.go +++ b/clientapi/auth/storage/accounts/postgres/storage.go @@ -164,7 +164,7 @@ func (d *Database) createAccount( } if err := d.profiles.insertProfile(ctx, txn, localpart); err != nil { if internal.IsUniqueConstraintViolationErr(err) { - return nil, internal.ErrSQLUserExists + return nil, internal.ErrUserExists } return nil, err } diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index e69d3bbfc..d356db2cb 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -830,7 +830,7 @@ func completeRegistration( acc, err := accountDB.CreateAccount(ctx, username, password, appserviceID) if err != nil { - if errors.Is(err, internal.ErrSQLUserExists) { // user already exists + if errors.Is(err, internal.ErrUserExists) { // user already exists return util.JSONResponse{ Code: http.StatusBadRequest, JSON: jsonerror.UserInUse("Desired user ID is already taken."), diff --git a/internal/sql.go b/internal/sql.go index e28a52a49..b8a706f1d 100644 --- a/internal/sql.go +++ b/internal/sql.go @@ -23,7 +23,7 @@ import ( ) // ErrUserExists is returned if a username already exists in the database. -var ErrSQLUserExists = errors.New("Username already exists") +var ErrUserExists = errors.New("Username already exists") // A Transaction is something that can be committed or rolledback. type Transaction interface {