diff options
author | Lunny Xiao <xiaolunwen@gmail.com> | 2021-11-10 13:13:16 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-10 13:13:16 +0800 |
commit | 33fca2b537d36cf998dd27425b2bb8ed5b0965f3 (patch) | |
tree | 817f392502e1c176a5cd7e80290520cb940a8416 /services/webhook/discord.go | |
parent | edbaa5d3f05b5ca397524587ba9db15edd61bc29 (diff) | |
download | gitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.tar.gz gitea-33fca2b537d36cf998dd27425b2bb8ed5b0965f3.zip |
Move webhook into models/webhook/ (#17579)
Diffstat (limited to 'services/webhook/discord.go')
-rw-r--r-- | services/webhook/discord.go | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/services/webhook/discord.go b/services/webhook/discord.go index 9a8f8a27a5..3de50a8a2f 100644 --- a/services/webhook/discord.go +++ b/services/webhook/discord.go @@ -10,7 +10,7 @@ import ( "strconv" "strings" - "code.gitea.io/gitea/models" + webhook_model "code.gitea.io/gitea/models/webhook" "code.gitea.io/gitea/modules/git" "code.gitea.io/gitea/modules/json" "code.gitea.io/gitea/modules/log" @@ -66,7 +66,7 @@ type ( ) // GetDiscordHook returns discord metadata -func GetDiscordHook(w *models.Webhook) *DiscordMeta { +func GetDiscordHook(w *webhook_model.Webhook) *DiscordMeta { s := &DiscordMeta{} if err := json.Unmarshal([]byte(w.Meta), s); err != nil { log.Error("webhook.GetDiscordHook(%d): %v", w.ID, err) @@ -191,7 +191,7 @@ func (d *DiscordPayload) PullRequest(p *api.PullRequestPayload) (api.Payloader, } // Review implements PayloadConvertor Review method -func (d *DiscordPayload) Review(p *api.PullRequestPayload, event models.HookEventType) (api.Payloader, error) { +func (d *DiscordPayload) Review(p *api.PullRequestPayload, event webhook_model.HookEventType) (api.Payloader, error) { var text, title string var color int switch p.Action { @@ -205,11 +205,11 @@ func (d *DiscordPayload) Review(p *api.PullRequestPayload, event models.HookEven text = p.Review.Content switch event { - case models.HookEventPullRequestReviewApproved: + case webhook_model.HookEventPullRequestReviewApproved: color = greenColor - case models.HookEventPullRequestReviewRejected: + case webhook_model.HookEventPullRequestReviewRejected: color = redColor - case models.HookEventPullRequestComment: + case webhook_model.HookEventPullRequestComment: color = greyColor default: color = yellowColor @@ -244,7 +244,7 @@ func (d *DiscordPayload) Release(p *api.ReleasePayload) (api.Payloader, error) { } // GetDiscordPayload converts a discord webhook into a DiscordPayload -func GetDiscordPayload(p api.Payloader, event models.HookEventType, meta string) (api.Payloader, error) { +func GetDiscordPayload(p api.Payloader, event webhook_model.HookEventType, meta string) (api.Payloader, error) { s := new(DiscordPayload) discord := &DiscordMeta{} @@ -257,14 +257,14 @@ func GetDiscordPayload(p api.Payloader, event models.HookEventType, meta string) return convertPayloader(s, p, event) } -func parseHookPullRequestEventType(event models.HookEventType) (string, error) { +func parseHookPullRequestEventType(event webhook_model.HookEventType) (string, error) { switch event { - case models.HookEventPullRequestReviewApproved: + case webhook_model.HookEventPullRequestReviewApproved: return "approved", nil - case models.HookEventPullRequestReviewRejected: + case webhook_model.HookEventPullRequestReviewRejected: return "rejected", nil - case models.HookEventPullRequestComment: + case webhook_model.HookEventPullRequestComment: return "comment", nil default: |