fix: own comments trigger NEW
This commit is contained in:
@@ -35,6 +35,7 @@ type mutationOperation struct {
|
||||
PRID string `json:"pull_request_id"`
|
||||
ThreadID string `json:"thread_id,omitempty"`
|
||||
Body string `json:"body,omitempty"`
|
||||
ReplyID string `json:"reply_id,omitempty"`
|
||||
Resolved bool `json:"resolved,omitempty"`
|
||||
Viewer string `json:"viewer,omitempty"`
|
||||
Original PullRequestMetadata `json:"original,omitempty"`
|
||||
@@ -372,9 +373,11 @@ func executeQueuedMutation(
|
||||
reason: "could not checkpoint the reply attempt", err: err,
|
||||
}
|
||||
}
|
||||
if _, err := writer.ReplyToThread(ctx, operation.ThreadID, operation.Body); err != nil {
|
||||
comment, err := writer.ReplyToThread(ctx, operation.ThreadID, operation.Body)
|
||||
if err != nil {
|
||||
return mutationReplayMsg{operation: operation, state: mutationReplayWaiting, details: details, err: err}
|
||||
}
|
||||
operation.ReplyID = comment.ID
|
||||
return verifying()
|
||||
case mutationResolution:
|
||||
if thread == nil {
|
||||
@@ -477,6 +480,9 @@ func queuedReplyPresent(details PRDetails, operation mutationOperation) bool {
|
||||
}
|
||||
matches := 0
|
||||
for _, comment := range thread.Comments {
|
||||
if operation.ReplyID != "" && comment.ID == operation.ReplyID {
|
||||
return true
|
||||
}
|
||||
if comment.Body == operation.Body && strings.EqualFold(comment.Author, operation.Viewer) &&
|
||||
!comment.CreatedAt.Before(operation.EnqueuedAt.Add(-time.Minute)) {
|
||||
matches++
|
||||
@@ -546,6 +552,10 @@ func (m App) projectQueuedMutations(details PRDetails) PRDetails {
|
||||
pendingID := "pending:" + operation.ID
|
||||
found := false
|
||||
for index := range thread.Comments {
|
||||
if queuedReplyMatchesComment(thread.Comments[index], operation) {
|
||||
found = true
|
||||
continue
|
||||
}
|
||||
if thread.Comments[index].ID == pendingID {
|
||||
thread.Comments[index].Pending = mutationNeedsAttention(operation)
|
||||
found = true
|
||||
@@ -573,6 +583,15 @@ func (m App) projectQueuedMutations(details PRDetails) PRDetails {
|
||||
return details
|
||||
}
|
||||
|
||||
func queuedReplyMatchesComment(comment ReviewComment, operation mutationOperation) bool {
|
||||
if operation.ReplyID != "" && comment.ID == operation.ReplyID {
|
||||
return true
|
||||
}
|
||||
return comment.Body == operation.Body &&
|
||||
strings.EqualFold(comment.Author, operation.Viewer) &&
|
||||
!comment.CreatedAt.Before(operation.EnqueuedAt.Add(-time.Minute))
|
||||
}
|
||||
|
||||
func mutationNeedsAttention(operation mutationOperation) bool {
|
||||
return operation.Blocked || operation.Unverified
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user