From d179b8b7ec7815ccac73e00f35f5cfbdc4ddbe2e Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Sun, 31 Jul 2022 14:38:32 +0200 Subject: bug: fix an issue where Id would be used, then changed due to metadata --- bug/op_add_comment.go | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'bug/op_add_comment.go') diff --git a/bug/op_add_comment.go b/bug/op_add_comment.go index b11afe34..eddd585a 100644 --- a/bug/op_add_comment.go +++ b/bug/op_add_comment.go @@ -79,16 +79,15 @@ type AddCommentTimelineItem struct { // IsAuthored is a sign post method for gqlgen func (a *AddCommentTimelineItem) IsAuthored() {} -// Convenience function to apply the operation -func AddComment(b Interface, author identity.Interface, unixTime int64, message string) (*AddCommentOperation, error) { - return AddCommentWithFiles(b, author, unixTime, message, nil) -} - -func AddCommentWithFiles(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash) (*AddCommentOperation, error) { - addCommentOp := NewAddCommentOp(author, unixTime, message, files) - if err := addCommentOp.Validate(); err != nil { +// AddComment is a convenience function to add a comment to a bug +func AddComment(b Interface, author identity.Interface, unixTime int64, message string, files []repository.Hash, metadata map[string]string) (*AddCommentOperation, error) { + op := NewAddCommentOp(author, unixTime, message, files) + for key, val := range metadata { + op.SetMetadata(key, val) + } + if err := op.Validate(); err != nil { return nil, err } - b.Append(addCommentOp) - return addCommentOp, nil + b.Append(op) + return op, nil } -- cgit