Skip to content

Commit be1726e

Browse files
6543lunny
authored andcommitted
rename webhook_services
1 parent de1ec3c commit be1726e

File tree

1 file changed

+36
-36
lines changed

1 file changed

+36
-36
lines changed

modules/notification/webhook/webhook.go

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
"code.gitea.io/gitea/modules/repository"
1414
"code.gitea.io/gitea/modules/setting"
1515
api "code.gitea.io/gitea/modules/structs"
16-
webhook_module "code.gitea.io/gitea/services/webhook"
16+
webhook_services "code.gitea.io/gitea/services/webhook"
1717
)
1818

1919
type webhookNotifier struct {
@@ -48,15 +48,15 @@ func (m *webhookNotifier) NotifyIssueClearLabels(doer *models.User, issue *model
4848
return
4949
}
5050

51-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
51+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
5252
Action: api.HookIssueLabelCleared,
5353
Index: issue.Index,
5454
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
5555
Repository: issue.Repo.APIFormat(mode),
5656
Sender: convert.ToUser(doer, false, false),
5757
})
5858
} else {
59-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
59+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
6060
Action: api.HookIssueLabelCleared,
6161
Index: issue.Index,
6262
Issue: convert.ToAPIIssue(issue),
@@ -74,7 +74,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
7474
mode, _ := models.AccessLevel(doer, repo)
7575

7676
// forked webhook
77-
if err := webhook_module.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
77+
if err := webhook_services.PrepareWebhooks(oldRepo, models.HookEventFork, &api.ForkPayload{
7878
Forkee: oldRepo.APIFormat(oldMode),
7979
Repo: repo.APIFormat(mode),
8080
Sender: convert.ToUser(doer, false, false),
@@ -86,7 +86,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
8686

8787
// Add to hook queue for created repo after session commit.
8888
if u.IsOrganization() {
89-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
89+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
9090
Action: api.HookRepoCreated,
9191
Repository: repo.APIFormat(models.AccessModeOwner),
9292
Organization: convert.ToUser(u, false, false),
@@ -99,7 +99,7 @@ func (m *webhookNotifier) NotifyForkRepository(doer *models.User, oldRepo, repo
9999

100100
func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.User, repo *models.Repository) {
101101
// Add to hook queue for created repo after session commit.
102-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
102+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
103103
Action: api.HookRepoCreated,
104104
Repository: repo.APIFormat(models.AccessModeOwner),
105105
Organization: convert.ToUser(u, false, false),
@@ -112,7 +112,7 @@ func (m *webhookNotifier) NotifyCreateRepository(doer *models.User, u *models.Us
112112
func (m *webhookNotifier) NotifyDeleteRepository(doer *models.User, repo *models.Repository) {
113113
u := repo.MustOwner()
114114

115-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
115+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventRepository, &api.RepositoryPayload{
116116
Action: api.HookRepoDeleted,
117117
Repository: repo.APIFormat(models.AccessModeOwner),
118118
Organization: convert.ToUser(u, false, false),
@@ -143,7 +143,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
143143
apiPullRequest.Action = api.HookIssueAssigned
144144
}
145145
// Assignee comment triggers a webhook
146-
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestAssign, apiPullRequest); err != nil {
146+
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestAssign, apiPullRequest); err != nil {
147147
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
148148
return
149149
}
@@ -161,7 +161,7 @@ func (m *webhookNotifier) NotifyIssueChangeAssignee(doer *models.User, issue *mo
161161
apiIssue.Action = api.HookIssueAssigned
162162
}
163163
// Assignee comment triggers a webhook
164-
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueAssign, apiIssue); err != nil {
164+
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueAssign, apiIssue); err != nil {
165165
log.Error("PrepareWebhooks [is_pull: %v, remove_assignee: %v]: %v", issue.IsPull, removed, err)
166166
return
167167
}
@@ -177,7 +177,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
177177
return
178178
}
179179
issue.PullRequest.Issue = issue
180-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
180+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
181181
Action: api.HookIssueEdited,
182182
Index: issue.Index,
183183
Changes: &api.ChangesPayload{
@@ -190,7 +190,7 @@ func (m *webhookNotifier) NotifyIssueChangeTitle(doer *models.User, issue *model
190190
Sender: convert.ToUser(doer, false, false),
191191
})
192192
} else {
193-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
193+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
194194
Action: api.HookIssueEdited,
195195
Index: issue.Index,
196196
Changes: &api.ChangesPayload{
@@ -229,7 +229,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
229229
} else {
230230
apiPullRequest.Action = api.HookIssueReOpened
231231
}
232-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest)
232+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, apiPullRequest)
233233
} else {
234234
apiIssue := &api.IssuePayload{
235235
Index: issue.Index,
@@ -242,7 +242,7 @@ func (m *webhookNotifier) NotifyIssueChangeStatus(doer *models.User, issue *mode
242242
} else {
243243
apiIssue.Action = api.HookIssueReOpened
244244
}
245-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue)
245+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, apiIssue)
246246
}
247247
if err != nil {
248248
log.Error("PrepareWebhooks [is_pull: %v, is_closed: %v]: %v", issue.IsPull, isClosed, err)
@@ -260,7 +260,7 @@ func (m *webhookNotifier) NotifyNewIssue(issue *models.Issue) {
260260
}
261261

262262
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
263-
if err := webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
263+
if err := webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
264264
Action: api.HookIssueOpened,
265265
Index: issue.Index,
266266
Issue: convert.ToAPIIssue(issue),
@@ -286,7 +286,7 @@ func (m *webhookNotifier) NotifyNewPullRequest(pull *models.PullRequest) {
286286
}
287287

288288
mode, _ := models.AccessLevel(pull.Issue.Poster, pull.Issue.Repo)
289-
if err := webhook_module.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
289+
if err := webhook_services.PrepareWebhooks(pull.Issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
290290
Action: api.HookIssueOpened,
291291
Index: pull.Issue.Index,
292292
PullRequest: convert.ToAPIPullRequest(pull),
@@ -302,7 +302,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
302302
var err error
303303
if issue.IsPull {
304304
issue.PullRequest.Issue = issue
305-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
305+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
306306
Action: api.HookIssueEdited,
307307
Index: issue.Index,
308308
Changes: &api.ChangesPayload{
@@ -315,7 +315,7 @@ func (m *webhookNotifier) NotifyIssueChangeContent(doer *models.User, issue *mod
315315
Sender: convert.ToUser(doer, false, false),
316316
})
317317
} else {
318-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
318+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssues, &api.IssuePayload{
319319
Action: api.HookIssueEdited,
320320
Index: issue.Index,
321321
Changes: &api.ChangesPayload{
@@ -352,7 +352,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
352352

353353
mode, _ := models.AccessLevel(doer, c.Issue.Repo)
354354
if c.Issue.IsPull {
355-
err = webhook_module.PrepareWebhooks(c.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
355+
err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
356356
Action: api.HookIssueCommentEdited,
357357
Issue: convert.ToAPIIssue(c.Issue),
358358
Comment: convert.ToComment(c),
@@ -366,7 +366,7 @@ func (m *webhookNotifier) NotifyUpdateComment(doer *models.User, c *models.Comme
366366
IsPull: true,
367367
})
368368
} else {
369-
err = webhook_module.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
369+
err = webhook_services.PrepareWebhooks(c.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
370370
Action: api.HookIssueCommentEdited,
371371
Issue: convert.ToAPIIssue(c.Issue),
372372
Comment: convert.ToComment(c),
@@ -392,7 +392,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
392392

393393
var err error
394394
if issue.IsPull {
395-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
395+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
396396
Action: api.HookIssueCommentCreated,
397397
Issue: convert.ToAPIIssue(issue),
398398
Comment: convert.ToComment(comment),
@@ -401,7 +401,7 @@ func (m *webhookNotifier) NotifyCreateIssueComment(doer *models.User, repo *mode
401401
IsPull: true,
402402
})
403403
} else {
404-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
404+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
405405
Action: api.HookIssueCommentCreated,
406406
Issue: convert.ToAPIIssue(issue),
407407
Comment: convert.ToComment(comment),
@@ -436,7 +436,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
436436
mode, _ := models.AccessLevel(doer, comment.Issue.Repo)
437437

438438
if comment.Issue.IsPull {
439-
err = webhook_module.PrepareWebhooks(comment.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
439+
err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventPullRequestComment, &api.IssueCommentPayload{
440440
Action: api.HookIssueCommentDeleted,
441441
Issue: convert.ToAPIIssue(comment.Issue),
442442
Comment: convert.ToComment(comment),
@@ -445,7 +445,7 @@ func (m *webhookNotifier) NotifyDeleteComment(doer *models.User, comment *models
445445
IsPull: true,
446446
})
447447
} else {
448-
err = webhook_module.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
448+
err = webhook_services.PrepareWebhooks(comment.Issue.Repo, models.HookEventIssueComment, &api.IssueCommentPayload{
449449
Action: api.HookIssueCommentDeleted,
450450
Issue: convert.ToAPIIssue(comment.Issue),
451451
Comment: convert.ToComment(comment),
@@ -485,15 +485,15 @@ func (m *webhookNotifier) NotifyIssueChangeLabels(doer *models.User, issue *mode
485485
log.Error("LoadIssue: %v", err)
486486
return
487487
}
488-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
488+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestLabel, &api.PullRequestPayload{
489489
Action: api.HookIssueLabelUpdated,
490490
Index: issue.Index,
491491
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
492492
Repository: issue.Repo.APIFormat(models.AccessModeNone),
493493
Sender: convert.ToUser(doer, false, false),
494494
})
495495
} else {
496-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
496+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueLabel, &api.IssuePayload{
497497
Action: api.HookIssueLabelUpdated,
498498
Index: issue.Index,
499499
Issue: convert.ToAPIIssue(issue),
@@ -527,15 +527,15 @@ func (m *webhookNotifier) NotifyIssueChangeMilestone(doer *models.User, issue *m
527527
log.Error("LoadIssue: %v", err)
528528
return
529529
}
530-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequestMilestone, &api.PullRequestPayload{
530+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequestMilestone, &api.PullRequestPayload{
531531
Action: hookAction,
532532
Index: issue.Index,
533533
PullRequest: convert.ToAPIPullRequest(issue.PullRequest),
534534
Repository: issue.Repo.APIFormat(mode),
535535
Sender: convert.ToUser(doer, false, false),
536536
})
537537
} else {
538-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{
538+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventIssueMilestone, &api.IssuePayload{
539539
Action: hookAction,
540540
Index: issue.Index,
541541
Issue: convert.ToAPIIssue(issue),
@@ -556,7 +556,7 @@ func (m *webhookNotifier) NotifyPushCommits(pusher *models.User, repo *models.Re
556556
return
557557
}
558558

559-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
559+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
560560
Ref: opts.RefFullName,
561561
Before: opts.OldCommitID,
562562
After: opts.NewCommitID,
@@ -602,7 +602,7 @@ func (*webhookNotifier) NotifyMergePullRequest(pr *models.PullRequest, doer *mod
602602
Action: api.HookIssueClosed,
603603
}
604604

605-
err = webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest)
605+
err = webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequest, apiPullRequest)
606606
if err != nil {
607607
log.Error("PrepareWebhooks: %v", err)
608608
}
@@ -621,7 +621,7 @@ func (m *webhookNotifier) NotifyPullRequestChangeTargetBranch(doer *models.User,
621621
}
622622
issue.PullRequest.Issue = issue
623623
mode, _ := models.AccessLevel(issue.Poster, issue.Repo)
624-
err = webhook_module.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
624+
err = webhook_services.PrepareWebhooks(issue.Repo, models.HookEventPullRequest, &api.PullRequestPayload{
625625
Action: api.HookIssueEdited,
626626
Index: issue.Index,
627627
Changes: &api.ChangesPayload{
@@ -665,7 +665,7 @@ func (m *webhookNotifier) NotifyPullRequestReview(pr *models.PullRequest, review
665665
log.Error("models.AccessLevel: %v", err)
666666
return
667667
}
668-
if err := webhook_module.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
668+
if err := webhook_services.PrepareWebhooks(review.Issue.Repo, reviewHookType, &api.PullRequestPayload{
669669
Action: api.HookIssueReviewed,
670670
Index: review.Issue.Index,
671671
PullRequest: convert.ToAPIPullRequest(pr),
@@ -699,7 +699,7 @@ func (m *webhookNotifier) NotifyCreateRef(pusher *models.User, repo *models.Repo
699699
}
700700
gitRepo.Close()
701701

702-
if err = webhook_module.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
702+
if err = webhook_services.PrepareWebhooks(repo, models.HookEventCreate, &api.CreatePayload{
703703
Ref: refName,
704704
Sha: shaSum,
705705
RefType: refType,
@@ -720,7 +720,7 @@ func (m *webhookNotifier) NotifyPullRequestSynchronized(doer *models.User, pr *m
720720
return
721721
}
722722

723-
if err := webhook_module.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequestSync, &api.PullRequestPayload{
723+
if err := webhook_services.PrepareWebhooks(pr.Issue.Repo, models.HookEventPullRequestSync, &api.PullRequestPayload{
724724
Action: api.HookIssueSynchronized,
725725
Index: pr.Issue.Index,
726726
PullRequest: convert.ToAPIPullRequest(pr),
@@ -736,7 +736,7 @@ func (m *webhookNotifier) NotifyDeleteRef(pusher *models.User, repo *models.Repo
736736
apiRepo := repo.APIFormat(models.AccessModeNone)
737737
refName := git.RefEndName(refFullName)
738738

739-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
739+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventDelete, &api.DeletePayload{
740740
Ref: refName,
741741
RefType: refType,
742742
PusherType: api.PusherTypeUser,
@@ -754,7 +754,7 @@ func sendReleaseHook(doer *models.User, rel *models.Release, action api.HookRele
754754
}
755755

756756
mode, _ := models.AccessLevel(rel.Publisher, rel.Repo)
757-
if err := webhook_module.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
757+
if err := webhook_services.PrepareWebhooks(rel.Repo, models.HookEventRelease, &api.ReleasePayload{
758758
Action: action,
759759
Release: convert.ToRelease(rel),
760760
Repository: rel.Repo.APIFormat(mode),
@@ -784,7 +784,7 @@ func (m *webhookNotifier) NotifySyncPushCommits(pusher *models.User, repo *model
784784
return
785785
}
786786

787-
if err := webhook_module.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
787+
if err := webhook_services.PrepareWebhooks(repo, models.HookEventPush, &api.PushPayload{
788788
Ref: opts.RefFullName,
789789
Before: opts.OldCommitID,
790790
After: opts.NewCommitID,

0 commit comments

Comments
 (0)