|
|
@ -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 { |
|
|
|