aboutsummaryrefslogtreecommitdiffstats
path: root/cache
diff options
context:
space:
mode:
Diffstat (limited to 'cache')
-rw-r--r--cache/bug_cache.go11
-rw-r--r--cache/repo_cache_bug.go14
2 files changed, 15 insertions, 10 deletions
diff --git a/cache/bug_cache.go b/cache/bug_cache.go
index e03b27ff..6caaeb11 100644
--- a/cache/bug_cache.go
+++ b/cache/bug_cache.go
@@ -209,7 +209,7 @@ func (c *BugCache) EditCreateCommentRaw(author *IdentityCache, unixTime int64, b
return op, c.notifyUpdated()
}
-func (c *BugCache) EditComment(target entity.Id, message string) (*bug.EditCommentOperation, error) {
+func (c *BugCache) EditComment(target entity.CombinedId, message string) (*bug.EditCommentOperation, error) {
author, err := c.repoCache.GetUserIdentity()
if err != nil {
return nil, err
@@ -218,9 +218,14 @@ func (c *BugCache) EditComment(target entity.Id, message string) (*bug.EditComme
return c.EditCommentRaw(author, time.Now().Unix(), target, message, nil)
}
-func (c *BugCache) EditCommentRaw(author *IdentityCache, unixTime int64, target entity.Id, message string, metadata map[string]string) (*bug.EditCommentOperation, error) {
+func (c *BugCache) EditCommentRaw(author *IdentityCache, unixTime int64, target entity.CombinedId, message string, metadata map[string]string) (*bug.EditCommentOperation, error) {
+ comment, err := c.Snapshot().SearchComment(target)
+ if err != nil {
+ return nil, err
+ }
+
c.mu.Lock()
- op, err := bug.EditComment(c.bug, author.Identity, unixTime, target, message, nil, metadata)
+ op, err := bug.EditComment(c.bug, author.Identity, unixTime, comment.TargetId(), message, nil, metadata)
c.mu.Unlock()
if err != nil {
return nil, err
diff --git a/cache/repo_cache_bug.go b/cache/repo_cache_bug.go
index 9843f9d9..226c4c13 100644
--- a/cache/repo_cache_bug.go
+++ b/cache/repo_cache_bug.go
@@ -263,7 +263,7 @@ func (c *RepoCache) resolveBugMatcher(f func(*BugExcerpt) bool) (entity.Id, erro
// ResolveComment search for a Bug/Comment combination matching the merged
// bug/comment Id prefix. Returns the Bug containing the Comment and the Comment's
// Id.
-func (c *RepoCache) ResolveComment(prefix string) (*BugCache, entity.Id, error) {
+func (c *RepoCache) ResolveComment(prefix string) (*BugCache, entity.CombinedId, error) {
bugPrefix, _ := entity.SeparateIds(prefix)
bugCandidate := make([]entity.Id, 0, 5)
@@ -277,7 +277,7 @@ func (c *RepoCache) ResolveComment(prefix string) (*BugCache, entity.Id, error)
c.muBug.RUnlock()
matchingBugIds := make([]entity.Id, 0, 5)
- matchingCommentId := entity.UnsetId
+ matchingCommentId := entity.UnsetCombinedId
var matchingBug *BugCache
// search for matching comments
@@ -286,22 +286,22 @@ func (c *RepoCache) ResolveComment(prefix string) (*BugCache, entity.Id, error)
for _, bugId := range bugCandidate {
b, err := c.ResolveBug(bugId)
if err != nil {
- return nil, entity.UnsetId, err
+ return nil, entity.UnsetCombinedId, err
}
for _, comment := range b.Snapshot().Comments {
- if comment.Id().HasPrefix(prefix) {
+ if comment.TargetId().HasPrefix(prefix) {
matchingBugIds = append(matchingBugIds, bugId)
matchingBug = b
- matchingCommentId = comment.Id()
+ matchingCommentId = comment.CombinedId()
}
}
}
if len(matchingBugIds) > 1 {
- return nil, entity.UnsetId, entity.NewErrMultipleMatch("bug/comment", matchingBugIds)
+ return nil, entity.UnsetCombinedId, entity.NewErrMultipleMatch("bug/comment", matchingBugIds)
} else if len(matchingBugIds) == 0 {
- return nil, entity.UnsetId, errors.New("comment doesn't exist")
+ return nil, entity.UnsetCombinedId, errors.New("comment doesn't exist")
}
return matchingBug, matchingCommentId, nil