Skip to content

Commit 5067294

Browse files
committed
fix lint
1 parent da07467 commit 5067294

File tree

3 files changed

+34
-8
lines changed

3 files changed

+34
-8
lines changed

models/repo_watch.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,21 @@ func NotifyWatchers(act *Action) error {
216216
return notifyWatchers(x, act)
217217
}
218218

219+
// NotifyWatchersActions creates batch of actions for every watcher.
220+
func NotifyWatchersActions(acts []*Action) error {
221+
sess := x.NewSession()
222+
defer sess.Close()
223+
if err := sess.Begin(); err != nil {
224+
return err
225+
}
226+
for _, act := range acts {
227+
if err := notifyWatchers(sess, act); err != nil {
228+
return err
229+
}
230+
}
231+
return sess.Commit()
232+
}
233+
219234
func watchIfAuto(e Engine, userID, repoID int64, isWrite bool) error {
220235
if !isWrite || !setting.Service.AutoWatchOnChanges {
221236
return nil

models/review.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,15 @@ func GetCurrentReview(reviewer *User, issue *Issue) (*Review, error) {
226226
return getCurrentReview(x, reviewer, issue)
227227
}
228228

229+
// ContentEmptyErr represents an content empty error
229230
type ContentEmptyErr struct {
230231
}
231232

232233
func (ContentEmptyErr) Error() string {
233234
return "Review content is empty"
234235
}
235236

237+
// IsContentEmptyErr returns true if err is a ContentEmptyErr
236238
func IsContentEmptyErr(err error) bool {
237239
_, ok := err.(ContentEmptyErr)
238240
return ok

modules/notification/action/action.go

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -130,19 +130,26 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
130130
return
131131
}
132132

133+
var actions = make([]*models.Action, 0, 10)
133134
for _, lines := range review.CodeComments {
134135
for _, comments := range lines {
135-
for _, comment := range comments {
136-
// TODO: how to handle???
137-
/*if err := sendCreateCommentAction(sess, opts, comm); err != nil {
138-
log.Warn("sendCreateCommentAction: %v", err)
139-
}*/
140-
content += "\n" + comment.Content
136+
for _, comm := range comments {
137+
actions = append(actions, &models.Action{
138+
ActUserID: review.Reviewer.ID,
139+
ActUser: review.Reviewer,
140+
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
141+
OpType: models.ActionCommentIssue,
142+
RepoID: review.Issue.RepoID,
143+
Repo: review.Issue.Repo,
144+
IsPrivate: review.Issue.Repo.IsPrivate,
145+
Comment: comm,
146+
CommentID: comm.ID,
147+
})
141148
}
142149
}
143150
}
144151

145-
if err := models.NotifyWatchers(&models.Action{
152+
actions = append(actions, &models.Action{
146153
ActUserID: review.Reviewer.ID,
147154
ActUser: review.Reviewer,
148155
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
@@ -152,7 +159,9 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
152159
IsPrivate: review.Issue.Repo.IsPrivate,
153160
Comment: comment,
154161
CommentID: comment.ID,
155-
}); err != nil {
162+
})
163+
164+
if err := models.NotifyWatchersActions(actions); err != nil {
156165
log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)
157166
}
158167
}

0 commit comments

Comments
 (0)