diff options
author | Michael Muré <batolettre@gmail.com> | 2021-05-27 11:08:53 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-05-27 11:08:53 +0200 |
commit | 76bdac7d11fd4f5d9cb52cd520c6b81f8d12665f (patch) | |
tree | 764d9a460a6dc95fdb88569c1a87e1210ee5e10c /api/graphql/resolvers | |
parent | 2e9c83a08366ec20dd60e7cce3306650a0ec7e1f (diff) | |
parent | e867663bf01841684da6c74a7bcac478cf99655a (diff) | |
download | git-bug-76bdac7d11fd4f5d9cb52cd520c6b81f8d12665f.tar.gz |
Merge pull request #682 from GlancingMind/webui-comment-and-reopen-bug
WebUI: Support comment-and-reopen a bug in one step
Diffstat (limited to 'api/graphql/resolvers')
-rw-r--r-- | api/graphql/resolvers/mutation.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go index b55270c2..aa99e93d 100644 --- a/api/graphql/resolvers/mutation.go +++ b/api/graphql/resolvers/mutation.go @@ -138,6 +138,44 @@ func (r mutationResolver) AddCommentAndClose(ctx context.Context, input models.A }, nil } +func (r mutationResolver) AddCommentAndReopen(ctx context.Context, input models.AddCommentAndReopenBugInput) (*models.AddCommentAndReopenBugPayload, error) { + repo, b, err := r.getBug(input.RepoRef, input.Prefix) + if err != nil { + return nil, err + } + + author, err := auth.UserFromCtx(ctx, repo) + if err != nil { + return nil, err + } + + opAddComment, err := b.AddCommentRaw(author, + time.Now().Unix(), + text.Cleanup(input.Message), + input.Files, + nil) + if err != nil { + return nil, err + } + + opReopen, err := b.OpenRaw(author, time.Now().Unix(), nil) + if err != nil { + return nil, err + } + + err = b.Commit() + if err != nil { + return nil, err + } + + return &models.AddCommentAndReopenBugPayload{ + ClientMutationID: input.ClientMutationID, + Bug: models.NewLoadedBug(b.Snapshot()), + CommentOperation: opAddComment, + StatusOperation: opReopen, + }, nil +} + func (r mutationResolver) EditComment(ctx context.Context, input models.EditCommentInput) (*models.EditCommentPayload, error) { repo, b, err := r.getBug(input.RepoRef, input.Prefix) if err != nil { |