diff --git a/database/drivers/mysqldriver/activities.go b/database/drivers/mysqldriver/activities.go index 92bf395..2078b45 100644 --- a/database/drivers/mysqldriver/activities.go +++ b/database/drivers/mysqldriver/activities.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "git.aiterp.net/stufflog/server/internal/generate" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -20,7 +20,7 @@ func (r *activityRepository) Find(ctx context.Context, id string) (*models.Activ err := r.db.GetContext(ctx, &activity, "SELECT * FROM activity WHERE activity_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Activity") + return nil, slerrors.NotFound("Activity") } return nil, err diff --git a/database/drivers/mysqldriver/issetasks.go b/database/drivers/mysqldriver/issetasks.go index 3ca418c..0cdadc1 100644 --- a/database/drivers/mysqldriver/issetasks.go +++ b/database/drivers/mysqldriver/issetasks.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "fmt" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -21,7 +21,7 @@ func (r *issueTaskRepository) Find(ctx context.Context, id string) (*models.Issu err := r.db.GetContext(ctx, &issueTask, "SELECT * FROM issue_task WHERE issue_task_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Issue task") + return nil, slerrors.NotFound("Issue task") } return nil, err diff --git a/database/drivers/mysqldriver/issues.go b/database/drivers/mysqldriver/issues.go index 6ffa1a4..5239f12 100644 --- a/database/drivers/mysqldriver/issues.go +++ b/database/drivers/mysqldriver/issues.go @@ -5,7 +5,7 @@ import ( "database/sql" "errors" "fmt" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -24,7 +24,7 @@ func (r *issueRepository) Find(ctx context.Context, id string) (*models.Issue, e err := r.db.GetContext(ctx, &issue, "SELECT * FROM issue WHERE issue_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Issue") + return nil, slerrors.NotFound("Issue") } return nil, err diff --git a/database/drivers/mysqldriver/issues_test.go b/database/drivers/mysqldriver/issues_test.go index 4f9d9b5..2c9cd51 100644 --- a/database/drivers/mysqldriver/issues_test.go +++ b/database/drivers/mysqldriver/issues_test.go @@ -2,7 +2,7 @@ package mysqldriver import ( "context" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/stretchr/testify/assert" "testing" @@ -122,7 +122,7 @@ func TestIssueRepository(t *testing.T) { result, err = issues.Find(ctx, "NONEXISTENT-666") assert.Error(t, err) assert.Nil(t, result) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) // LIST results, err := issues.List(ctx, models.IssueFilter{}) diff --git a/database/drivers/mysqldriver/items.go b/database/drivers/mysqldriver/items.go index 45a0a7c..17a7cee 100644 --- a/database/drivers/mysqldriver/items.go +++ b/database/drivers/mysqldriver/items.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "git.aiterp.net/stufflog/server/internal/generate" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -19,7 +19,7 @@ func (r *itemRepository) Find(ctx context.Context, id string) (*models.Item, err err := r.db.GetContext(ctx, &item, "SELECT * FROM item WHERE item_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Project") + return nil, slerrors.NotFound("Project") } return nil, err diff --git a/database/drivers/mysqldriver/items_test.go b/database/drivers/mysqldriver/items_test.go index b32c5c4..c91b631 100644 --- a/database/drivers/mysqldriver/items_test.go +++ b/database/drivers/mysqldriver/items_test.go @@ -2,7 +2,7 @@ package mysqldriver import ( "context" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/stretchr/testify/assert" "testing" @@ -93,7 +93,7 @@ func TestItemRepository(t *testing.T) { // FIND't result, err = items.Find(ctx, "Iobviouslyinvalidid") assert.Error(t, err) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) assert.Nil(t, result) // LIST diff --git a/database/drivers/mysqldriver/projects.go b/database/drivers/mysqldriver/projects.go index 77bef21..968360d 100644 --- a/database/drivers/mysqldriver/projects.go +++ b/database/drivers/mysqldriver/projects.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "errors" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -19,7 +19,7 @@ func (r *projectRepository) Find(ctx context.Context, id string) (*models.Projec err := r.db.GetContext(ctx, &project, "SELECT * FROM project WHERE project_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Project") + return nil, slerrors.NotFound("Project") } return nil, err diff --git a/database/drivers/mysqldriver/projects_test.go b/database/drivers/mysqldriver/projects_test.go index 98d790c..aecea75 100644 --- a/database/drivers/mysqldriver/projects_test.go +++ b/database/drivers/mysqldriver/projects_test.go @@ -2,7 +2,7 @@ package mysqldriver import ( "context" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/stretchr/testify/assert" "testing" @@ -62,7 +62,7 @@ func TestProjectRepository(t *testing.T) { // FIND't result, err = projects.Find(ctx, "BLARGH") assert.Error(t, err) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) assert.Nil(t, result) // LIST diff --git a/database/drivers/mysqldriver/projectstatuses.go b/database/drivers/mysqldriver/projectstatuses.go index 702f873..66d2073 100644 --- a/database/drivers/mysqldriver/projectstatuses.go +++ b/database/drivers/mysqldriver/projectstatuses.go @@ -3,7 +3,7 @@ package mysqldriver import ( "context" "database/sql" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -18,7 +18,7 @@ func (r *projectStatusRepository) Find(ctx context.Context, projectID string, na err := r.db.GetContext(ctx, &projectStatus, "SELECT * FROM project_status WHERE project_id=? AND name=?", projectID, name) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Project status") + return nil, slerrors.NotFound("Project status") } return nil, err diff --git a/database/drivers/mysqldriver/projectstatuses_test.go b/database/drivers/mysqldriver/projectstatuses_test.go index 8161241..6236438 100644 --- a/database/drivers/mysqldriver/projectstatuses_test.go +++ b/database/drivers/mysqldriver/projectstatuses_test.go @@ -2,7 +2,7 @@ package mysqldriver import ( "context" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/stretchr/testify/assert" "testing" @@ -85,11 +85,11 @@ func TestProjectStatusRepository(t *testing.T) { // FINDn't result, err = statuses.Find(ctx, project3.ID, projectStatus6.Name) assert.Error(t, err) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) assert.Nil(t, result) result, err = statuses.Find(ctx, project2.ID, "Non-existent Name") assert.Error(t, err) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) assert.Nil(t, result) // LIST diff --git a/database/drivers/mysqldriver/session.go b/database/drivers/mysqldriver/session.go index 0a26ed7..f0953ec 100644 --- a/database/drivers/mysqldriver/session.go +++ b/database/drivers/mysqldriver/session.go @@ -3,7 +3,7 @@ package mysqldriver import ( "context" "database/sql" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/jmoiron/sqlx" "time" @@ -18,12 +18,12 @@ func (r *sessionRepository) Find(ctx context.Context, id string) (*models.Sessio err := r.db.GetContext(ctx, &session, "SELECT * FROM session WHERE session_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("Session") + return nil, slerrors.NotFound("Session") } return nil, err } else if time.Now().After(session.ExpiryTime) { - return nil, xlerrors.NotFound("Session") + return nil, slerrors.NotFound("Session") } return &session, nil diff --git a/database/drivers/mysqldriver/users.go b/database/drivers/mysqldriver/users.go index 9c1df3c..9ff7093 100644 --- a/database/drivers/mysqldriver/users.go +++ b/database/drivers/mysqldriver/users.go @@ -4,7 +4,7 @@ import ( "context" "database/sql" "errors" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" sq "github.com/Masterminds/squirrel" "github.com/jmoiron/sqlx" @@ -19,7 +19,7 @@ func (r *userRepository) Find(ctx context.Context, id string) (*models.User, err err := r.db.GetContext(ctx, &user, "SELECT * FROM user WHERE user_id=?", id) if err != nil { if err == sql.ErrNoRows { - return nil, xlerrors.NotFound("User") + return nil, slerrors.NotFound("User") } return nil, err diff --git a/database/drivers/mysqldriver/users_test.go b/database/drivers/mysqldriver/users_test.go index 2ddbd51..f7e6150 100644 --- a/database/drivers/mysqldriver/users_test.go +++ b/database/drivers/mysqldriver/users_test.go @@ -2,7 +2,7 @@ package mysqldriver import ( "context" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/stretchr/testify/assert" "testing" @@ -59,7 +59,7 @@ func TestUserRepository(t *testing.T) { // FIND't result, err = users.Find(ctx, "NonExistent") assert.Error(t, err) - assert.True(t, xlerrors.IsNotFound(err)) + assert.True(t, slerrors.IsNotFound(err)) assert.Nil(t, result) // LIST diff --git a/graph/loaders/userloader.go b/graph/loaders/userloader.go index 5d9295e..7359d1a 100644 --- a/graph/loaders/userloader.go +++ b/graph/loaders/userloader.go @@ -3,7 +3,7 @@ package loaders import ( "context" "git.aiterp.net/stufflog/server/database/repositories" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "time" ) @@ -47,7 +47,7 @@ func NewUserLoader(ctx context.Context, userRepo repositories.UserRepository) *U if user != nil { results[i] = user } else { - errors[i] = xlerrors.NotFound("User") + errors[i] = slerrors.NotFound("User") } } diff --git a/graph/resolvers/issue.resolvers.go b/graph/resolvers/issue.resolvers.go index 5fbc7f5..5fd2adb 100644 --- a/graph/resolvers/issue.resolvers.go +++ b/graph/resolvers/issue.resolvers.go @@ -9,7 +9,7 @@ import ( "git.aiterp.net/stufflog/server/graph/graphcore" "git.aiterp.net/stufflog/server/graph/graphutil" "git.aiterp.net/stufflog/server/graph/loaders" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" ) @@ -55,7 +55,7 @@ func (r *issueResolver) Status(ctx context.Context, obj *models.Issue) (*models. } status, err := r.Database.ProjectStatuses().Find(ctx, obj.ProjectID, obj.StatusName) - if xlerrors.IsNotFound(err) { + if slerrors.IsNotFound(err) { return &models.ProjectStatus{ ProjectID: obj.ProjectID, Stage: obj.StatusStage, diff --git a/graph/resolvers/issuetask.resolvers.go b/graph/resolvers/issuetask.resolvers.go index a1764fd..b639975 100644 --- a/graph/resolvers/issuetask.resolvers.go +++ b/graph/resolvers/issuetask.resolvers.go @@ -12,7 +12,7 @@ import ( "git.aiterp.net/stufflog/server/graph/graphcore" "git.aiterp.net/stufflog/server/graph/graphutil" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" ) @@ -57,7 +57,7 @@ func (r *issueTaskResolver) Status(ctx context.Context, obj *models.IssueTask) ( // Find it in the database. TODO: DataLoader status, err := r.Database.ProjectStatuses().Find(ctx, projectID, obj.StatusName) - if xlerrors.IsNotFound(err) { + if slerrors.IsNotFound(err) { return &models.ProjectStatus{ ProjectID: projectID, Stage: obj.StatusStage, diff --git a/graph/resolvers/mutation.resolvers.go b/graph/resolvers/mutation.resolvers.go index e1620bf..af736d3 100644 --- a/graph/resolvers/mutation.resolvers.go +++ b/graph/resolvers/mutation.resolvers.go @@ -10,14 +10,14 @@ import ( "time" "git.aiterp.net/stufflog/server/graph/graphcore" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" ) func (r *mutationResolver) CreateProject(ctx context.Context, input graphcore.ProjectCreateInput) (*models.Project, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } project := &models.Project{ @@ -50,7 +50,7 @@ func (r *mutationResolver) CreateProject(ctx context.Context, input graphcore.Pr func (r *mutationResolver) CreateActivity(ctx context.Context, input graphcore.ActivityCreateInput) (*models.Activity, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } project, err := r.Database.Projects().Find(ctx, input.ProjectID) @@ -58,7 +58,7 @@ func (r *mutationResolver) CreateActivity(ctx context.Context, input graphcore.A return nil, err } if perm, err := r.Auth.ProjectPermission(ctx, *project); err != nil || !perm.CanManageActivities() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } activity := &models.Activity{ @@ -87,7 +87,7 @@ func (r *mutationResolver) CreateActivity(ctx context.Context, input graphcore.A func (r *mutationResolver) EditActivity(ctx context.Context, input graphcore.ActivityEditInput) (*models.Activity, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } activity, err := r.Database.Activities().Find(ctx, input.ActivityID) @@ -100,7 +100,7 @@ func (r *mutationResolver) EditActivity(ctx context.Context, input graphcore.Act return nil, err } if perm, err := r.Auth.ProjectPermission(ctx, *project); err != nil || !perm.CanManageActivities() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if input.SetName != nil { @@ -127,7 +127,7 @@ func (r *mutationResolver) EditActivity(ctx context.Context, input graphcore.Act func (r *mutationResolver) CreateItem(ctx context.Context, input *graphcore.ItemCreateInput) (*models.Item, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if input.Name == "" { @@ -162,7 +162,7 @@ func (r *mutationResolver) EditItem(ctx context.Context, input *graphcore.ItemEd func (r *mutationResolver) CreateIssue(ctx context.Context, input graphcore.IssueCreateInput) (*models.Issue, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } project, err := r.Database.Projects().Find(ctx, input.ProjectID) @@ -170,7 +170,7 @@ func (r *mutationResolver) CreateIssue(ctx context.Context, input graphcore.Issu return nil, err } if perm, err := r.Auth.ProjectPermission(ctx, *project); err != nil || !perm.CanManageOwnIssue() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } status, err := r.Database.ProjectStatuses().Find(ctx, project.ID, input.StatusName) @@ -209,7 +209,7 @@ func (r *mutationResolver) CreateIssue(ctx context.Context, input graphcore.Issu func (r *mutationResolver) CreateIssueTask(ctx context.Context, input graphcore.IssueTaskCreateInput) (*models.IssueTask, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } issue, err := r.Database.Issues().Find(ctx, input.IssueID) @@ -217,7 +217,7 @@ func (r *mutationResolver) CreateIssueTask(ctx context.Context, input graphcore. return nil, err } if perm, err := r.Auth.IssuePermission(ctx, *issue); err != nil || !perm.CanManageOwnIssue() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } status, err := r.Database.ProjectStatuses().Find(ctx, issue.ProjectID, input.StatusName) @@ -229,7 +229,7 @@ func (r *mutationResolver) CreateIssueTask(ctx context.Context, input graphcore. if err != nil { return nil, err } else if activity.ProjectID != issue.ProjectID { - return nil, xlerrors.NotFound("Activity") + return nil, slerrors.NotFound("Activity") } issueTask := &models.IssueTask{ @@ -261,7 +261,7 @@ func (r *mutationResolver) CreateIssueTask(ctx context.Context, input graphcore. func (r *mutationResolver) EditIssueTask(ctx context.Context, input graphcore.IssueTaskEditInput) (*models.IssueTask, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } task, err := r.Database.IssueTasks().Find(ctx, input.IssueTaskID) @@ -274,7 +274,7 @@ func (r *mutationResolver) EditIssueTask(ctx context.Context, input graphcore.Is return nil, err } if perm, err := r.Auth.IssuePermission(ctx, *issue); err != nil || !perm.CanManageOwnIssue() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if input.SetName != nil { diff --git a/graph/resolvers/project.resolvers.go b/graph/resolvers/project.resolvers.go index 32f2a10..d605623 100644 --- a/graph/resolvers/project.resolvers.go +++ b/graph/resolvers/project.resolvers.go @@ -8,7 +8,7 @@ import ( "git.aiterp.net/stufflog/server/graph/graphcore" "git.aiterp.net/stufflog/server/graph/loaders" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" ) @@ -29,7 +29,7 @@ func (r *projectResolver) Issues(ctx context.Context, obj *models.Project, filte func (r *projectResolver) Permissions(ctx context.Context, obj *models.Project) ([]*models.ProjectPermission, error) { if perm, err := r.Auth.ProjectPermission(ctx, *obj); err != nil || !perm.CanManagePermissions() { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } return r.Database.Projects().ListPermissions(ctx, *obj) diff --git a/graph/resolvers/query.resolvers.go b/graph/resolvers/query.resolvers.go index 5f4e72e..32c1c1d 100644 --- a/graph/resolvers/query.resolvers.go +++ b/graph/resolvers/query.resolvers.go @@ -6,15 +6,16 @@ package resolvers import ( "context" "errors" + "git.aiterp.net/stufflog/server/graph/graphcore" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" ) func (r *queryResolver) Issue(ctx context.Context, id string) (*models.Issue, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } issue, err := r.Database.Issues().Find(ctx, id) @@ -32,7 +33,7 @@ func (r *queryResolver) Issue(ctx context.Context, id string) (*models.Issue, er func (r *queryResolver) Issues(ctx context.Context, filter *models.IssueFilter) ([]*models.Issue, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if filter == nil { @@ -60,7 +61,7 @@ func (r *queryResolver) Issues(ctx context.Context, filter *models.IssueFilter) func (r *queryResolver) Item(ctx context.Context, id string) (*models.Item, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } return r.Database.Items().Find(ctx, id) @@ -69,7 +70,7 @@ func (r *queryResolver) Item(ctx context.Context, id string) (*models.Item, erro func (r *queryResolver) Items(ctx context.Context, filter *models.ItemFilter) ([]*models.Item, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if filter == nil { @@ -82,7 +83,7 @@ func (r *queryResolver) Items(ctx context.Context, filter *models.ItemFilter) ([ func (r *queryResolver) ItemTags(ctx context.Context) ([]string, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } return r.Database.Items().GetTags(ctx) @@ -91,7 +92,7 @@ func (r *queryResolver) ItemTags(ctx context.Context) ([]string, error) { func (r *queryResolver) Project(ctx context.Context, id string) (*models.Project, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } project, err := r.Database.Projects().Find(ctx, id) @@ -109,7 +110,7 @@ func (r *queryResolver) Project(ctx context.Context, id string) (*models.Project func (r *queryResolver) Projects(ctx context.Context, filter *models.ProjectFilter) ([]*models.Project, error) { user := r.Auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } skipCheck := false diff --git a/internal/xlerrors/notfound.go b/internal/slerrors/notfound.go similarity index 94% rename from internal/xlerrors/notfound.go rename to internal/slerrors/notfound.go index 68bc3ff..9b493f8 100644 --- a/internal/xlerrors/notfound.go +++ b/internal/slerrors/notfound.go @@ -1,4 +1,4 @@ -package xlerrors +package slerrors type notFoundError struct { Subject string diff --git a/internal/xlerrors/permission.go b/internal/slerrors/permission.go similarity index 81% rename from internal/xlerrors/permission.go rename to internal/slerrors/permission.go index 6d4a6a3..a2567e7 100644 --- a/internal/xlerrors/permission.go +++ b/internal/slerrors/permission.go @@ -1,4 +1,4 @@ -package xlerrors +package slerrors import "errors" diff --git a/main.go b/main.go index d4ca566..995a311 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,7 @@ import ( "git.aiterp.net/stufflog/server/database" "git.aiterp.net/stufflog/server/graph" "git.aiterp.net/stufflog/server/internal/generate" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "git.aiterp.net/stufflog/server/services" "github.com/99designs/gqlgen/graphql/playground" @@ -61,7 +61,7 @@ func main() { newPass := generate.Generate(20, "") admin, err := db.Users().Find(timeout, "Admin") - if xlerrors.IsNotFound(err) { + if slerrors.IsNotFound(err) { admin = &models.User{ ID: "Admin", Name: "Administrator", diff --git a/services/auth.go b/services/auth.go index 866c95a..9589c83 100644 --- a/services/auth.go +++ b/services/auth.go @@ -5,7 +5,7 @@ import ( "errors" "git.aiterp.net/stufflog/server/database/repositories" "git.aiterp.net/stufflog/server/internal/generate" - "git.aiterp.net/stufflog/server/internal/xlerrors" + "git.aiterp.net/stufflog/server/internal/slerrors" "git.aiterp.net/stufflog/server/models" "github.com/gin-gonic/gin" "math/rand" @@ -68,7 +68,7 @@ func (auth *Auth) Login(ctx context.Context, username, password string) (*models func (auth *Auth) Logout(ctx context.Context) (*models.User, error) { user := auth.UserFromContext(ctx) if user == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } c, ok := ctx.Value(ginCtxKey).(*gin.Context) @@ -84,7 +84,7 @@ func (auth *Auth) Logout(ctx context.Context) (*models.User, error) { func (auth *Auth) CreateUser(ctx context.Context, username, password, name string, active, admin bool) (*models.User, error) { loggedInUser := auth.UserFromContext(ctx) if loggedInUser == nil || !loggedInUser.Admin { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } user := &models.User{ @@ -114,7 +114,7 @@ func (auth *Auth) UserFromContext(ctx context.Context) *models.User { func (auth *Auth) ProjectPermission(ctx context.Context, project models.Project) (*models.ProjectPermission, error) { user := auth.UserFromContext(ctx) if user == nil || !user.Active { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } permission, err := auth.projects.GetPermission(ctx, project, *user) @@ -122,7 +122,7 @@ func (auth *Auth) ProjectPermission(ctx context.Context, project models.Project) return nil, ErrInternalPermissionFailure } if permission.Level == models.ProjectPermissionLevelNoAccess { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } return permission, nil @@ -131,7 +131,7 @@ func (auth *Auth) ProjectPermission(ctx context.Context, project models.Project) func (auth *Auth) IssuePermission(ctx context.Context, issue models.Issue) (*models.ProjectPermission, error) { user := auth.UserFromContext(ctx) if user == nil || !user.Active { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } isOwnedOrAssigned := issue.AssigneeID == user.ID || issue.OwnerID == user.ID @@ -141,10 +141,10 @@ func (auth *Auth) IssuePermission(ctx context.Context, issue models.Issue) (*mod return nil, ErrInternalPermissionFailure } if permission.Level == models.ProjectPermissionLevelNoAccess { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if !(permission.CanViewAnyIssue() || (permission.CanViewOwnIssue() && isOwnedOrAssigned)) { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } return permission, nil @@ -184,7 +184,7 @@ func (auth *Auth) CheckGinSession(c *gin.Context) { func (auth *Auth) EditUser(ctx context.Context, username string, setName *string, currentPassword *string, newPassword *string) (*models.User, error) { loggedInUser := auth.UserFromContext(ctx) if loggedInUser == nil { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } user, err := auth.users.Find(ctx, username) @@ -193,7 +193,7 @@ func (auth *Auth) EditUser(ctx context.Context, username string, setName *string } if user.ID != loggedInUser.ID && !loggedInUser.Admin { - return nil, xlerrors.PermissionDenied + return nil, slerrors.PermissionDenied } if newPassword != nil {