Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions models/issues/comment.go
Original file line number Diff line number Diff line change
Expand Up @@ -715,7 +715,8 @@ func (c *Comment) LoadReactions(ctx context.Context, repo *repo_model.Repository
return nil
}

func (c *Comment) loadReview(ctx context.Context) (err error) {
// LoadReview loads the associated review
func (c *Comment) LoadReview(ctx context.Context) (err error) {
if c.ReviewID == 0 {
return nil
}
Expand All @@ -732,11 +733,6 @@ func (c *Comment) loadReview(ctx context.Context) (err error) {
return nil
}

// LoadReview loads the associated review
func (c *Comment) LoadReview(ctx context.Context) error {
return c.loadReview(ctx)
}

// DiffSide returns "previous" if Comment.Line is a LOC of the previous changes and "proposed" if it is a LOC of the proposed changes.
func (c *Comment) DiffSide() string {
if c.Line < 0 {
Expand Down Expand Up @@ -856,7 +852,7 @@ func updateCommentInfos(ctx context.Context, opts *CreateCommentOptions, comment
}
if comment.ReviewID != 0 {
if comment.Review == nil {
if err := comment.loadReview(ctx); err != nil {
if err := comment.LoadReview(ctx); err != nil {
return err
}
}
Expand Down
24 changes: 24 additions & 0 deletions services/notify/notify.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ func DeleteWikiPage(ctx context.Context, doer *user_model.User, repo *repo_model
func CreateIssueComment(ctx context.Context, doer *user_model.User, repo *repo_model.Repository,
issue *issues_model.Issue, comment *issues_model.Comment, mentions []*user_model.User,
) {
if err := comment.LoadReview(ctx); err != nil {
log.Error("LoadReview: %v", err)
return
} else if comment.Review != nil && comment.Review.Type == issues_model.ReviewTypePending {
// Pending review comments updating should not triggered
return
}

for _, notifier := range notifiers {
notifier.CreateIssueComment(ctx, doer, repo, issue, comment, mentions)
}
Expand Down Expand Up @@ -156,13 +164,29 @@ func PullReviewDismiss(ctx context.Context, doer *user_model.User, review *issue

// UpdateComment notifies update comment to notifiers
func UpdateComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment, oldContent string) {
if err := c.LoadReview(ctx); err != nil {
log.Error("LoadReview: %v", err)
return
} else if c.Review != nil && c.Review.Type == issues_model.ReviewTypePending {
// Pending review comments updating should not triggered
return
}

for _, notifier := range notifiers {
notifier.UpdateComment(ctx, doer, c, oldContent)
}
}

// DeleteComment notifies delete comment to notifiers
func DeleteComment(ctx context.Context, doer *user_model.User, c *issues_model.Comment) {
if err := c.LoadReview(ctx); err != nil {
log.Error("LoadReview: %v", err)
return
} else if c.Review != nil && c.Review.Type == issues_model.ReviewTypePending {
// Pending review comments updating should not triggered
return
}

for _, notifier := range notifiers {
notifier.DeleteComment(ctx, doer, c)
}
Expand Down