diff options
Diffstat (limited to 'modules/notification')
-rw-r--r-- | modules/notification/action/action.go | 6 | ||||
-rw-r--r-- | modules/notification/base/notifier.go | 14 | ||||
-rw-r--r-- | modules/notification/base/null.go | 9 | ||||
-rw-r--r-- | modules/notification/indexer/indexer.go | 4 | ||||
-rw-r--r-- | modules/notification/mail/mail.go | 4 | ||||
-rw-r--r-- | modules/notification/notification.go | 6 | ||||
-rw-r--r-- | modules/notification/ui/ui.go | 20 | ||||
-rw-r--r-- | modules/notification/webhook/webhook.go | 7 |
8 files changed, 23 insertions, 47 deletions
diff --git a/modules/notification/action/action.go b/modules/notification/action/action.go index bdf4a50995..ed4ce3dd1a 100644 --- a/modules/notification/action/action.go +++ b/modules/notification/action/action.go @@ -25,9 +25,7 @@ type actionNotifier struct { base.NullNotifier } -var ( - _ base.Notifier = &actionNotifier{} -) +var _ base.Notifier = &actionNotifier{} // NewNotifier create a new actionNotifier notifier func NewNotifier() base.Notifier { @@ -220,7 +218,7 @@ func (a *actionNotifier) NotifyPullRequestReview(pr *models.PullRequest, review return } - var actions = make([]*models.Action, 0, 10) + actions := make([]*models.Action, 0, 10) for _, lines := range review.CodeComments { for _, comments := range lines { for _, comm := range comments { diff --git a/modules/notification/base/notifier.go b/modules/notification/base/notifier.go index 177864994d..7f5caa3bcc 100644 --- a/modules/notification/base/notifier.go +++ b/modules/notification/base/notifier.go @@ -14,14 +14,12 @@ import ( // Notifier defines an interface to notify receiver type Notifier interface { Run() - - NotifyCreateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) - NotifyMigrateRepository(doer *user_model.User, u *user_model.User, repo *repo_model.Repository) + NotifyCreateRepository(doer, u *user_model.User, repo *repo_model.Repository) + NotifyMigrateRepository(doer, u *user_model.User, repo *repo_model.Repository) NotifyDeleteRepository(doer *user_model.User, repo *repo_model.Repository) NotifyForkRepository(doer *user_model.User, oldRepo, repo *repo_model.Repository) NotifyRenameRepository(doer *user_model.User, repo *repo_model.Repository, oldRepoName string) NotifyTransferRepository(doer *user_model.User, repo *repo_model.Repository, oldOwnerName string) - NotifyNewIssue(issue *models.Issue, mentions []*user_model.User) NotifyIssueChangeStatus(*user_model.User, *models.Issue, *models.Comment, bool) NotifyIssueChangeMilestone(doer *user_model.User, issue *models.Issue, oldMilestoneID int64) @@ -32,8 +30,7 @@ type Notifier interface { NotifyIssueChangeTitle(doer *user_model.User, issue *models.Issue, oldTitle string) NotifyIssueChangeRef(doer *user_model.User, issue *models.Issue, oldRef string) NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue, - addedLabels []*models.Label, removedLabels []*models.Label) - + addedLabels, removedLabels []*models.Label) NotifyNewPullRequest(pr *models.PullRequest, mentions []*user_model.User) NotifyMergePullRequest(*models.PullRequest, *user_model.User) NotifyPullRequestSynchronized(doer *user_model.User, pr *models.PullRequest) @@ -42,23 +39,18 @@ type Notifier interface { NotifyPullRequestChangeTargetBranch(doer *user_model.User, pr *models.PullRequest, oldBranch string) NotifyPullRequestPushCommits(doer *user_model.User, pr *models.PullRequest, comment *models.Comment) NotifyPullRevieweDismiss(doer *user_model.User, review *models.Review, comment *models.Comment) - NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository, issue *models.Issue, comment *models.Comment, mentions []*user_model.User) NotifyUpdateComment(*user_model.User, *models.Comment, string) NotifyDeleteComment(*user_model.User, *models.Comment) - NotifyNewRelease(rel *models.Release) NotifyUpdateRelease(doer *user_model.User, rel *models.Release) NotifyDeleteRelease(doer *user_model.User, rel *models.Release) - NotifyPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) NotifyCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName, refID string) NotifyDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) - NotifySyncPushCommits(pusher *user_model.User, repo *repo_model.Repository, opts *repository.PushUpdateOptions, commits *repository.PushCommits) NotifySyncCreateRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName, refID string) NotifySyncDeleteRef(doer *user_model.User, repo *repo_model.Repository, refType, refFullName string) - NotifyRepoPendingTransfer(doer, newOwner *user_model.User, repo *repo_model.Repository) } diff --git a/modules/notification/base/null.go b/modules/notification/base/null.go index 9524f02f1b..bd52b843a7 100644 --- a/modules/notification/base/null.go +++ b/modules/notification/base/null.go @@ -12,12 +12,9 @@ import ( ) // NullNotifier implements a blank notifier -type NullNotifier struct { -} +type NullNotifier struct{} -var ( - _ Notifier = &NullNotifier{} -) +var _ Notifier = &NullNotifier{} // Run places a place holder function func (*NullNotifier) Run() { @@ -118,7 +115,7 @@ func (*NullNotifier) NotifyIssueChangeRef(doer *user_model.User, issue *models.I // NotifyIssueChangeLabels places a place holder function func (*NullNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue, - addedLabels []*models.Label, removedLabels []*models.Label) { + addedLabels, removedLabels []*models.Label) { } // NotifyCreateRepository places a place holder function diff --git a/modules/notification/indexer/indexer.go b/modules/notification/indexer/indexer.go index 715ec724c3..26f19e7791 100644 --- a/modules/notification/indexer/indexer.go +++ b/modules/notification/indexer/indexer.go @@ -22,9 +22,7 @@ type indexerNotifier struct { base.NullNotifier } -var ( - _ base.Notifier = &indexerNotifier{} -) +var _ base.Notifier = &indexerNotifier{} // NewNotifier create a new indexerNotifier notifier func NewNotifier() base.Notifier { diff --git a/modules/notification/mail/mail.go b/modules/notification/mail/mail.go index b96871597f..94ee16ff8c 100644 --- a/modules/notification/mail/mail.go +++ b/modules/notification/mail/mail.go @@ -21,9 +21,7 @@ type mailNotifier struct { base.NullNotifier } -var ( - _ base.Notifier = &mailNotifier{} -) +var _ base.Notifier = &mailNotifier{} // NewNotifier create a new mailNotifier notifier func NewNotifier() base.Notifier { diff --git a/modules/notification/notification.go b/modules/notification/notification.go index 201f652b3c..a0acd01561 100644 --- a/modules/notification/notification.go +++ b/modules/notification/notification.go @@ -18,9 +18,7 @@ import ( "code.gitea.io/gitea/modules/setting" ) -var ( - notifiers []base.Notifier -) +var notifiers []base.Notifier // RegisterNotifier providers method to receive notify messages func RegisterNotifier(notifier base.Notifier) { @@ -203,7 +201,7 @@ func NotifyIssueChangeRef(doer *user_model.User, issue *models.Issue, oldRef str // NotifyIssueChangeLabels notifies change labels to notifiers func NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue, - addedLabels []*models.Label, removedLabels []*models.Label) { + addedLabels, removedLabels []*models.Label) { for _, notifier := range notifiers { notifier.NotifyIssueChangeLabels(doer, issue, addedLabels, removedLabels) } diff --git a/modules/notification/ui/ui.go b/modules/notification/ui/ui.go index fd44cd15fd..ecedd70193 100644 --- a/modules/notification/ui/ui.go +++ b/modules/notification/ui/ui.go @@ -29,9 +29,7 @@ type ( } ) -var ( - _ base.Notifier = ¬ificationService{} -) +var _ base.Notifier = ¬ificationService{} // NewNotifier create a new notificationService notifier func NewNotifier() base.Notifier { @@ -55,7 +53,7 @@ func (ns *notificationService) Run() { func (ns *notificationService) NotifyCreateIssueComment(doer *user_model.User, repo *repo_model.Repository, issue *models.Issue, comment *models.Comment, mentions []*user_model.User) { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: issue.ID, NotificationAuthorID: doer.ID, } @@ -64,7 +62,7 @@ func (ns *notificationService) NotifyCreateIssueComment(doer *user_model.User, r } _ = ns.issueQueue.Push(opts) for _, mention := range mentions { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: issue.ID, NotificationAuthorID: doer.ID, ReceiverID: mention.ID, @@ -153,7 +151,7 @@ func (ns *notificationService) NotifyNewPullRequest(pr *models.PullRequest, ment } func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r *models.Review, c *models.Comment, mentions []*user_model.User) { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: pr.Issue.ID, NotificationAuthorID: r.Reviewer.ID, } @@ -162,7 +160,7 @@ func (ns *notificationService) NotifyPullRequestReview(pr *models.PullRequest, r } _ = ns.issueQueue.Push(opts) for _, mention := range mentions { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: pr.Issue.ID, NotificationAuthorID: r.Reviewer.ID, ReceiverID: mention.ID, @@ -186,7 +184,7 @@ func (ns *notificationService) NotifyPullRequestCodeComment(pr *models.PullReque } func (ns *notificationService) NotifyPullRequestPushCommits(doer *user_model.User, pr *models.PullRequest, comment *models.Comment) { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: pr.IssueID, NotificationAuthorID: doer.ID, CommentID: comment.ID, @@ -195,7 +193,7 @@ func (ns *notificationService) NotifyPullRequestPushCommits(doer *user_model.Use } func (ns *notificationService) NotifyPullRevieweDismiss(doer *user_model.User, review *models.Review, comment *models.Comment) { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: review.IssueID, NotificationAuthorID: doer.ID, CommentID: comment.ID, @@ -205,7 +203,7 @@ func (ns *notificationService) NotifyPullRevieweDismiss(doer *user_model.User, r func (ns *notificationService) NotifyIssueChangeAssignee(doer *user_model.User, issue *models.Issue, assignee *user_model.User, removed bool, comment *models.Comment) { if !removed { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: issue.ID, NotificationAuthorID: doer.ID, ReceiverID: assignee.ID, @@ -221,7 +219,7 @@ func (ns *notificationService) NotifyIssueChangeAssignee(doer *user_model.User, func (ns *notificationService) NotifyPullReviewRequest(doer *user_model.User, issue *models.Issue, reviewer *user_model.User, isRequest bool, comment *models.Comment) { if isRequest { - var opts = issueNotificationOpts{ + opts := issueNotificationOpts{ IssueID: issue.ID, NotificationAuthorID: doer.ID, ReceiverID: reviewer.ID, diff --git a/modules/notification/webhook/webhook.go b/modules/notification/webhook/webhook.go index 39b50b3cd1..ea70faa3c7 100644 --- a/modules/notification/webhook/webhook.go +++ b/modules/notification/webhook/webhook.go @@ -29,9 +29,7 @@ type webhookNotifier struct { base.NullNotifier } -var ( - _ base.Notifier = &webhookNotifier{} -) +var _ base.Notifier = &webhookNotifier{} // NewNotifier create a new webhookNotifier notifier func NewNotifier() base.Notifier { @@ -497,11 +495,10 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *user_model.User, comment *mo if err != nil { log.Error("PrepareWebhooks [comment_id: %d]: %v", comment.ID, err) } - } func (m *webhookNotifier) NotifyIssueChangeLabels(doer *user_model.User, issue *models.Issue, - addedLabels []*models.Label, removedLabels []*models.Label) { + addedLabels, removedLabels []*models.Label) { ctx, _, finished := process.GetManager().AddContext(graceful.GetManager().HammerContext(), fmt.Sprintf("webhook.NotifyIssueChangeLabels User: %s[%d] Issue[%d] #%d in [%d]", doer.Name, doer.ID, issue.ID, issue.Index, issue.RepoID)) defer finished() |