mirror of
https://gitee.com/gitea/gitea
synced 2025-11-12 20:40:25 +08:00
fix lint
This commit is contained in:
@@ -216,6 +216,21 @@ func NotifyWatchers(act *Action) error {
|
|||||||
return notifyWatchers(x, act)
|
return notifyWatchers(x, act)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// NotifyWatchersActions creates batch of actions for every watcher.
|
||||||
|
func NotifyWatchersActions(acts []*Action) error {
|
||||||
|
sess := x.NewSession()
|
||||||
|
defer sess.Close()
|
||||||
|
if err := sess.Begin(); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
for _, act := range acts {
|
||||||
|
if err := notifyWatchers(sess, act); err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sess.Commit()
|
||||||
|
}
|
||||||
|
|
||||||
func watchIfAuto(e Engine, userID, repoID int64, isWrite bool) error {
|
func watchIfAuto(e Engine, userID, repoID int64, isWrite bool) error {
|
||||||
if !isWrite || !setting.Service.AutoWatchOnChanges {
|
if !isWrite || !setting.Service.AutoWatchOnChanges {
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ func GetCurrentReview(reviewer *User, issue *Issue) (*Review, error) {
|
|||||||
return getCurrentReview(x, reviewer, issue)
|
return getCurrentReview(x, reviewer, issue)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ContentEmptyErr represents an content empty error
|
||||||
type ContentEmptyErr struct {
|
type ContentEmptyErr struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -233,6 +234,7 @@ func (ContentEmptyErr) Error() string {
|
|||||||
return "Review content is empty"
|
return "Review content is empty"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IsContentEmptyErr returns true if err is a ContentEmptyErr
|
||||||
func IsContentEmptyErr(err error) bool {
|
func IsContentEmptyErr(err error) bool {
|
||||||
_, ok := err.(ContentEmptyErr)
|
_, ok := err.(ContentEmptyErr)
|
||||||
return ok
|
return ok
|
||||||
|
|||||||
@@ -130,19 +130,26 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var actions = make([]*models.Action, 0, 10)
|
||||||
for _, lines := range review.CodeComments {
|
for _, lines := range review.CodeComments {
|
||||||
for _, comments := range lines {
|
for _, comments := range lines {
|
||||||
for _, comment := range comments {
|
for _, comm := range comments {
|
||||||
// TODO: how to handle???
|
actions = append(actions, &models.Action{
|
||||||
/*if err := sendCreateCommentAction(sess, opts, comm); err != nil {
|
ActUserID: review.Reviewer.ID,
|
||||||
log.Warn("sendCreateCommentAction: %v", err)
|
ActUser: review.Reviewer,
|
||||||
}*/
|
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
|
||||||
content += "\n" + comment.Content
|
OpType: models.ActionCommentIssue,
|
||||||
|
RepoID: review.Issue.RepoID,
|
||||||
|
Repo: review.Issue.Repo,
|
||||||
|
IsPrivate: review.Issue.Repo.IsPrivate,
|
||||||
|
Comment: comm,
|
||||||
|
CommentID: comm.ID,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := models.NotifyWatchers(&models.Action{
|
actions = append(actions, &models.Action{
|
||||||
ActUserID: review.Reviewer.ID,
|
ActUserID: review.Reviewer.ID,
|
||||||
ActUser: review.Reviewer,
|
ActUser: review.Reviewer,
|
||||||
Content: fmt.Sprintf("%d|%s", review.Issue.Index, strings.Split(content, "\n")[0]),
|
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
|
|||||||
IsPrivate: review.Issue.Repo.IsPrivate,
|
IsPrivate: review.Issue.Repo.IsPrivate,
|
||||||
Comment: comment,
|
Comment: comment,
|
||||||
CommentID: comment.ID,
|
CommentID: comment.ID,
|
||||||
}); err != nil {
|
})
|
||||||
|
|
||||||
|
if err := models.NotifyWatchersActions(actions); err != nil {
|
||||||
log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)
|
log.Error("notify watchers '%d/%d': %v", review.Reviewer.ID, review.Issue.RepoID, err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user