Fix notification (#10331)

mj
Lunny Xiao 4 years ago committed by GitHub
parent f0a43a068f
commit 21e771c41b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -19,9 +19,9 @@ type (
} }
issueNotificationOpts struct { issueNotificationOpts struct {
issueID int64 IssueID int64
commentID int64 CommentID int64
notificationAuthorID int64 NotificationAuthorID int64
} }
) )
@ -39,7 +39,7 @@ func NewNotifier() base.Notifier {
func (ns *notificationService) handle(data ...queue.Data) { func (ns *notificationService) handle(data ...queue.Data) {
for _, datum := range data { for _, datum := range data {
opts := datum.(issueNotificationOpts) opts := datum.(issueNotificationOpts)
if err := models.CreateOrUpdateIssueNotifications(opts.issueID, opts.commentID, opts.notificationAuthorID); err != nil { if err := models.CreateOrUpdateIssueNotifications(opts.IssueID, opts.CommentID, opts.NotificationAuthorID); err != nil {
log.Error("Was unable to create issue notification: %v", err) log.Error("Was unable to create issue notification: %v", err)
} }
} }
@ -52,33 +52,33 @@ func (ns *notificationService) Run() {
func (ns *notificationService) NotifyCreateIssueComment(doer *models.User, repo *models.Repository, func (ns *notificationService) NotifyCreateIssueComment(doer *models.User, repo *models.Repository,
issue *models.Issue, comment *models.Comment) { issue *models.Issue, comment *models.Comment) {
var opts = issueNotificationOpts{ var opts = issueNotificationOpts{
issueID: issue.ID, IssueID: issue.ID,
notificationAuthorID: doer.ID, NotificationAuthorID: doer.ID,
} }
if comment != nil { if comment != nil {
opts.commentID = comment.ID opts.CommentID = comment.ID
} }
_ = ns.issueQueue.Push(opts) _ = ns.issueQueue.Push(opts)
} }
func (ns *notificationService) NotifyNewIssue(issue *models.Issue) { func (ns *notificationService) NotifyNewIssue(issue *models.Issue) {
_ = ns.issueQueue.Push(issueNotificationOpts{ _ = ns.issueQueue.Push(issueNotificationOpts{
issueID: issue.ID, IssueID: issue.ID,
notificationAuthorID: issue.Poster.ID, NotificationAuthorID: issue.Poster.ID,
}) })
} }
func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) { func (ns *notificationService) NotifyIssueChangeStatus(doer *models.User, issue *models.Issue, actionComment *models.Comment, isClosed bool) {
_ = ns.issueQueue.Push(issueNotificationOpts{ _ = ns.issueQueue.Push(issueNotificationOpts{
issueID: issue.ID, IssueID: issue.ID,
notificationAuthorID: doer.ID, NotificationAuthorID: doer.ID,
}) })
} }
func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) { func (ns *notificationService) NotifyMergePullRequest(pr *models.PullRequest, doer *models.User) {
_ = ns.issueQueue.Push(issueNotificationOpts{ _ = ns.issueQueue.Push(issueNotificationOpts{
issueID: pr.Issue.ID, IssueID: pr.Issue.ID,
notificationAuthorID: doer.ID, NotificationAuthorID: doer.ID,
}) })
} }
@ -88,18 +88,18 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest) {
return return
} }
_ = ns.issueQueue.Push(issueNotificationOpts{ _ = ns.issueQueue.Push(issueNotificationOpts{
issueID: pr.Issue.ID, IssueID: pr.Issue.ID,
notificationAuthorID: pr.Issue.PosterID, NotificationAuthorID: pr.Issue.PosterID,
}) })
} }
func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment) { func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment) {
var opts = issueNotificationOpts{ var opts = issueNotificationOpts{
issueID: pr.Issue.ID, IssueID: pr.Issue.ID,
notificationAuthorID: r.Reviewer.ID, NotificationAuthorID: r.Reviewer.ID,
} }
if c != nil { if c != nil {
opts.commentID = c.ID opts.CommentID = c.ID
} }
_ = ns.issueQueue.Push(opts) _ = ns.issueQueue.Push(opts)
} }

Loading…
Cancel
Save