diff options
author | Michael Muré <batolettre@gmail.com> | 2021-03-24 20:28:06 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-24 20:28:06 +0100 |
commit | fb6b2d873e1bbc653aa84ddce56c842202e00c33 (patch) | |
tree | f722d8ac4381dd770b2cb96bf66478feabc94678 /api/graphql/resolvers/mutation.go | |
parent | 01b949091290a3bfd5870c6457c941db1abf3d67 (diff) | |
parent | bd6159a25b548f8f939f137b70dcf77a722e70dc (diff) | |
download | git-bug-fb6b2d873e1bbc653aa84ddce56c842202e00c33.tar.gz |
Merge pull request #602 from GlancingMind/upstream-4-interface-to-edit-issues
WebUI: Edit comments and inspect edit history
Diffstat (limited to 'api/graphql/resolvers/mutation.go')
-rw-r--r-- | api/graphql/resolvers/mutation.go | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/api/graphql/resolvers/mutation.go b/api/graphql/resolvers/mutation.go index 642a4fb9..9cd936a6 100644 --- a/api/graphql/resolvers/mutation.go +++ b/api/graphql/resolvers/mutation.go @@ -5,6 +5,7 @@ import ( "time" "github.com/MichaelMure/git-bug/api/auth" + "github.com/MichaelMure/git-bug/entity" "github.com/MichaelMure/git-bug/api/graphql/graph" "github.com/MichaelMure/git-bug/api/graphql/models" "github.com/MichaelMure/git-bug/bug" @@ -89,6 +90,34 @@ func (r mutationResolver) AddComment(ctx context.Context, input models.AddCommen }, 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 { + return nil, err + } + + author, err := auth.UserFromCtx(ctx, repo) + if err != nil { + return nil, err + } + + op, err := b.EditCommentRaw(author, time.Now().Unix(), entity.Id(input.Target), input.Message, nil) + if err != nil { + return nil, err + } + + err = b.Commit() + if err != nil { + return nil, err + } + + return &models.EditCommentPayload{ + ClientMutationID: input.ClientMutationID, + Bug: models.NewLoadedBug(b.Snapshot()), + Operation: op, + }, nil +} + func (r mutationResolver) ChangeLabels(ctx context.Context, input *models.ChangeLabelInput) (*models.ChangeLabelPayload, error) { repo, b, err := r.getBug(input.RepoRef, input.Prefix) if err != nil { |