diff options
author | Alexander Scharinger <rng.dynamics@gmail.com> | 2021-04-11 22:08:21 +0200 |
---|---|---|
committer | Michael Muré <batolettre@gmail.com> | 2021-04-17 20:03:33 +0200 |
commit | 6a5ffd94e0c7a2b9373981f99c4798eda601f4da (patch) | |
tree | a63b24b34333dff04ac9416f9944b65ae6f67c8b /bug/op_edit_comment.go | |
parent | c71d26d513e4e5e36e6983e05dee4ad28ec664c7 (diff) | |
download | git-bug-6a5ffd94e0c7a2b9373981f99c4798eda601f4da.tar.gz |
Fix ID string in order to find correct bug instance
Diffstat (limited to 'bug/op_edit_comment.go')
-rw-r--r-- | bug/op_edit_comment.go | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/bug/op_edit_comment.go b/bug/op_edit_comment.go index 3e6634e4..a69cb599 100644 --- a/bug/op_edit_comment.go +++ b/bug/op_edit_comment.go @@ -34,12 +34,12 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { // Todo: currently any message can be edited, even by a different author // crypto signature are needed. - snapshot.addActor(op.Author_) + // Recreate the Comment Id to match on + commentId := entity.CombineIds(snapshot.Id(), op.Target) var target TimelineItem - for i, item := range snapshot.Timeline { - if item.Id() == op.Target { + if item.Id() == commentId { target = snapshot.Timeline[i] break } @@ -51,7 +51,7 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { } comment := Comment{ - id: op.Target, + id: commentId, Message: op.Message, Files: op.Files, UnixTime: timestamp.Timestamp(op.UnixTime), @@ -62,12 +62,18 @@ func (op *EditCommentOperation) Apply(snapshot *Snapshot) { target.Append(comment) case *AddCommentTimelineItem: target.Append(comment) + default: + // somehow, the target matched on something that is not a comment + // we make the op a no-op + return } + snapshot.addActor(op.Author_) + // Updating the corresponding comment for i := range snapshot.Comments { - if snapshot.Comments[i].Id() == op.Target { + if snapshot.Comments[i].Id() == commentId { snapshot.Comments[i].Message = op.Message snapshot.Comments[i].Files = op.Files break |