diff --git a/docs/content/doc/features/webhooks.en-us.md b/docs/content/doc/features/webhooks.en-us.md index 5d792f5f5..7a88f2a5e 100644 --- a/docs/content/doc/features/webhooks.en-us.md +++ b/docs/content/doc/features/webhooks.en-us.md @@ -27,6 +27,7 @@ All event pushes are POST requests. The methods currently supported are: - Telegram - Microsoft Teams - Feishu +- Wechatwork ### Event information diff --git a/docs/content/doc/features/webhooks.zh-cn.md b/docs/content/doc/features/webhooks.zh-cn.md index fe9008717..f3a312eee 100644 --- a/docs/content/doc/features/webhooks.zh-cn.md +++ b/docs/content/doc/features/webhooks.zh-cn.md @@ -15,4 +15,17 @@ menu: # Webhooks +Gitea 的存储 webhook。这可以有存储库管路设定页 `/:username/:reponame/settings/hooks` 中的。Webhook 也可以按照组织调整或全系统调整,所有时间的推送都是POST请求 +。此方法目前被下列服务支援: + +- Gitea (也可以是 GET 請求) +- Gogs +- Slack +- Discord +- Dingtalk +- Telegram +- Microsoft Teams +- Feishu +- Wechatwork + ## TBD diff --git a/docs/content/doc/features/webhooks.zh-tw.md b/docs/content/doc/features/webhooks.zh-tw.md index 0d1c564f6..697b41391 100644 --- a/docs/content/doc/features/webhooks.zh-tw.md +++ b/docs/content/doc/features/webhooks.zh-tw.md @@ -26,6 +26,7 @@ Gitea 的儲存庫事件支援 web hook。這可以有儲存庫管理員在設 - Telegram - Microsoft Teams - Feishu +- Wechatwork ### 事件資訊 diff --git a/models/migrations/v161.go b/models/migrations/v161.go index 4ca9f0121..7ef06b4c2 100644 --- a/models/migrations/v161.go +++ b/models/migrations/v161.go @@ -19,18 +19,20 @@ func convertTaskTypeToString(x *xorm.Engine) error { MSTEAMS FEISHU MATRIX + WECHATWORK ) hookTaskTypes := map[int]string{ - GITEA: "gitea", - GOGS: "gogs", - SLACK: "slack", - DISCORD: "discord", - DINGTALK: "dingtalk", - TELEGRAM: "telegram", - MSTEAMS: "msteams", - FEISHU: "feishu", - MATRIX: "matrix", + GITEA: "gitea", + GOGS: "gogs", + SLACK: "slack", + DISCORD: "discord", + DINGTALK: "dingtalk", + TELEGRAM: "telegram", + MSTEAMS: "msteams", + FEISHU: "feishu", + MATRIX: "matrix", + WECHATWORK: "wechatwork", } type HookTask struct { diff --git a/models/migrations/v162.go b/models/migrations/v162.go index 9dd175cd3..cf2baadbc 100644 --- a/models/migrations/v162.go +++ b/models/migrations/v162.go @@ -19,18 +19,20 @@ func convertWebhookTaskTypeToString(x *xorm.Engine) error { MSTEAMS FEISHU MATRIX + WECHATWORK ) hookTaskTypes := map[int]string{ - GITEA: "gitea", - GOGS: "gogs", - SLACK: "slack", - DISCORD: "discord", - DINGTALK: "dingtalk", - TELEGRAM: "telegram", - MSTEAMS: "msteams", - FEISHU: "feishu", - MATRIX: "matrix", + GITEA: "gitea", + GOGS: "gogs", + SLACK: "slack", + DISCORD: "discord", + DINGTALK: "dingtalk", + TELEGRAM: "telegram", + MSTEAMS: "msteams", + FEISHU: "feishu", + MATRIX: "matrix", + WECHATWORK: "wechatwork", } type Webhook struct { diff --git a/models/webhook.go b/models/webhook.go index 29cfcf6ed..9c8c0a568 100644 --- a/models/webhook.go +++ b/models/webhook.go @@ -114,15 +114,16 @@ type HookType = string // Types of webhooks const ( - GITEA HookType = "gitea" - GOGS HookType = "gogs" - SLACK HookType = "slack" - DISCORD HookType = "discord" - DINGTALK HookType = "dingtalk" - TELEGRAM HookType = "telegram" - MSTEAMS HookType = "msteams" - FEISHU HookType = "feishu" - MATRIX HookType = "matrix" + GITEA HookType = "gitea" + GOGS HookType = "gogs" + SLACK HookType = "slack" + DISCORD HookType = "discord" + DINGTALK HookType = "dingtalk" + TELEGRAM HookType = "telegram" + MSTEAMS HookType = "msteams" + FEISHU HookType = "feishu" + MATRIX HookType = "matrix" + WECHATWORK HookType = "wechatwork" ) // HookStatus is the status of a web hook diff --git a/modules/setting/webhook.go b/modules/setting/webhook.go index 4a0c593c8..8ef54f5cb 100644 --- a/modules/setting/webhook.go +++ b/modules/setting/webhook.go @@ -36,7 +36,7 @@ func newWebhookService() { Webhook.QueueLength = sec.Key("QUEUE_LENGTH").MustInt(1000) Webhook.DeliverTimeout = sec.Key("DELIVER_TIMEOUT").MustInt(5) Webhook.SkipTLSVerify = sec.Key("SKIP_TLS_VERIFY").MustBool() - Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix"} + Webhook.Types = []string{"gitea", "gogs", "slack", "discord", "dingtalk", "telegram", "msteams", "feishu", "matrix", "wechatwork"} Webhook.PagingNum = sec.Key("PAGING_NUM").MustInt(10) Webhook.ProxyURL = sec.Key("PROXY_URL").MustString("") if Webhook.ProxyURL != "" { diff --git a/modules/structs/hook.go b/modules/structs/hook.go index e4ec99df4..ad86cb35a 100644 --- a/modules/structs/hook.go +++ b/modules/structs/hook.go @@ -42,7 +42,7 @@ type CreateHookOptionConfig map[string]string // CreateHookOption options when create a hook type CreateHookOption struct { // required: true - // enum: dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu + // enum: dingtalk,discord,gitea,gogs,msteams,slack,telegram,feishu,wechatwork Type string `json:"type" binding:"Required"` // required: true Config CreateHookOptionConfig `json:"config" binding:"Required"` diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini index 2ee17ef36..373ee9457 100644 --- a/options/locale/locale_cs-CZ.ini +++ b/options/locale/locale_cs-CZ.ini @@ -1758,6 +1758,7 @@ settings.add_telegram_hook_desc=Integrovat Telegram do vašeho settings.add_matrix_hook_desc=Integrovat Matrix do vašeho repozitáře. settings.add_msteams_hook_desc=Integrovat Microsoft Teams do vašeho repozitáře. settings.add_feishu_hook_desc=Integrovat Feishu do vašeho repozitáře. +settings.add_wechatwork_hook_desc=Integrovat Wechatwork do vašeho repozitáře. settings.deploy_keys=Klíče pro nasazení settings.add_deploy_key=Přidat klíč pro nasazení settings.deploy_key_desc=Klíče pro nasazení mají k tomuto repozitáři přístup pouze pro čtení. diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini index 2479bc5bb..760c02611 100644 --- a/options/locale/locale_en-US.ini +++ b/options/locale/locale_en-US.ini @@ -1848,6 +1848,7 @@ settings.add_telegram_hook_desc = Integrate Telegram into your settings.add_matrix_hook_desc = Integrate Matrix into your repository. settings.add_msteams_hook_desc = Integrate Microsoft Teams into your repository. settings.add_feishu_hook_desc = Integrate Feishu into your repository. +settings.add_Wechat_hook_desc = Integrate Wechatwork into your repository. settings.deploy_keys = Deploy Keys settings.add_deploy_key = Add Deploy Key settings.deploy_key_desc = Deploy keys have read-only pull access to the repository. diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini index 60a2e5c9f..9e1374cec 100644 --- a/options/locale/locale_zh-CN.ini +++ b/options/locale/locale_zh-CN.ini @@ -1848,6 +1848,7 @@ settings.add_telegram_hook_desc=将 Telegram 集成到您的仓 settings.add_matrix_hook_desc=将 Matrix 集成到您的仓库中。 settings.add_msteams_hook_desc=将 Microsoft Teams 集成到您的仓库中。 settings.add_feishu_hook_desc=将 Feishu 集成到您的仓库中。 +settings.add_wechatwork_hook_desc=将 Wechatwork 集成到您的仓库中。 settings.deploy_keys=部署密钥 settings.add_deploy_key=添加部署密钥 settings.deploy_key_desc=部署密钥具有对仓库的只读拉取权限。 diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini index e8c0e3c92..39f5b38e4 100644 --- a/options/locale/locale_zh-TW.ini +++ b/options/locale/locale_zh-TW.ini @@ -1833,6 +1833,7 @@ settings.add_telegram_hook_desc=將 Telegram 整合到您的儲 settings.add_matrix_hook_desc=將 Matrix 整合到您的儲存庫。 settings.add_msteams_hook_desc=將 Microsoft Teams 整合到您的儲存庫。 settings.add_feishu_hook_desc=將 Feishu 整合到您的儲存庫。 +settings.add_wechatwork_hook_desc=将 Wechatwork 整合到您的儲存庫。 settings.deploy_keys=部署金鑰 settings.add_deploy_key=新增部署金鑰 settings.deploy_key_desc=部署金鑰具有唯讀權限,可拉取此儲存庫。 diff --git a/public/img/wechatwork.png b/public/img/wechatwork.png new file mode 100644 index 000000000..296225fb8 Binary files /dev/null and b/public/img/wechatwork.png differ diff --git a/routers/web/repo/webhook.go b/routers/web/repo/webhook.go index e8d86db51..30fa98f80 100644 --- a/routers/web/repo/webhook.go +++ b/routers/web/repo/webhook.go @@ -638,6 +638,50 @@ func FeishuHooksNewPost(ctx *context.Context) { ctx.Redirect(orCtx.Link) } +// WechatworkHooksNewPost response for creating wechatwork hook +func WechatworkHooksNewPost(ctx *context.Context) { + form := web.GetForm(ctx).(*forms.NewWechatWorkHookForm) + + ctx.Data["Title"] = ctx.Tr("repo.settings") + ctx.Data["PageIsSettingsHooks"] = true + ctx.Data["PageIsSettingsHooksNew"] = true + ctx.Data["Webhook"] = models.Webhook{HookEvent: &models.HookEvent{}} + ctx.Data["HookType"] = models.WECHATWORK + + orCtx, err := getOrgRepoCtx(ctx) + if err != nil { + ctx.ServerError("getOrgRepoCtx", err) + return + } + + if ctx.HasError() { + ctx.HTML(http.StatusOK, orCtx.NewTemplate) + return + } + + w := &models.Webhook{ + RepoID: orCtx.RepoID, + URL: form.PayloadURL, + ContentType: models.ContentTypeJSON, + HookEvent: ParseHookEvent(form.WebhookForm), + IsActive: form.Active, + Type: models.WECHATWORK, + Meta: "", + OrgID: orCtx.OrgID, + IsSystemWebhook: orCtx.IsSystemWebhook, + } + if err := w.UpdateEvent(); err != nil { + ctx.ServerError("UpdateEvent", err) + return + } else if err := models.CreateWebhook(w); err != nil { + ctx.ServerError("CreateWebhook", err) + return + } + + ctx.Flash.Success(ctx.Tr("repo.settings.add_hook_success")) + ctx.Redirect(orCtx.Link) +} + func checkWebhook(ctx *context.Context) (*orgRepoCtx, *models.Webhook) { ctx.Data["RequireHighlightJS"] = true @@ -1062,6 +1106,39 @@ func FeishuHooksEditPost(ctx *context.Context) { ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID)) } +// WechatworkHooksEditPost response for editing wechatwork hook +func WechatworkHooksEditPost(ctx *context.Context) { + form := web.GetForm(ctx).(*forms.NewWechatWorkHookForm) + ctx.Data["Title"] = ctx.Tr("repo.settings") + ctx.Data["PageIsSettingsHooks"] = true + ctx.Data["PageIsSettingsHooksEdit"] = true + + orCtx, w := checkWebhook(ctx) + if ctx.Written() { + return + } + ctx.Data["Webhook"] = w + + if ctx.HasError() { + ctx.HTML(http.StatusOK, orCtx.NewTemplate) + return + } + + w.URL = form.PayloadURL + w.HookEvent = ParseHookEvent(form.WebhookForm) + w.IsActive = form.Active + if err := w.UpdateEvent(); err != nil { + ctx.ServerError("UpdateEvent", err) + return + } else if err := models.UpdateWebhook(w); err != nil { + ctx.ServerError("UpdateWebhook", err) + return + } + + ctx.Flash.Success(ctx.Tr("repo.settings.update_hook_success")) + ctx.Redirect(fmt.Sprintf("%s/%d", orCtx.Link, w.ID)) +} + // TestWebhook test if web hook is work fine func TestWebhook(ctx *context.Context) { hookID := ctx.ParamsInt64(":id") diff --git a/routers/web/web.go b/routers/web/web.go index 9baef5296..d06a7fc88 100644 --- a/routers/web/web.go +++ b/routers/web/web.go @@ -425,6 +425,7 @@ func RegisterRoutes(m *web.Route) { m.Post("/matrix/{id}", bindIgnErr(forms.NewMatrixHookForm{}), repo.MatrixHooksEditPost) m.Post("/msteams/{id}", bindIgnErr(forms.NewMSTeamsHookForm{}), repo.MSTeamsHooksEditPost) m.Post("/feishu/{id}", bindIgnErr(forms.NewFeishuHookForm{}), repo.FeishuHooksEditPost) + m.Post("/wechatwork/{id}", bindIgnErr(forms.NewWechatWorkHookForm{}), repo.WechatworkHooksEditPost) }, webhooksEnabled) m.Group("/{configType:default-hooks|system-hooks}", func() { @@ -438,6 +439,8 @@ func RegisterRoutes(m *web.Route) { m.Post("/matrix/new", bindIgnErr(forms.NewMatrixHookForm{}), repo.MatrixHooksNewPost) m.Post("/msteams/new", bindIgnErr(forms.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost) m.Post("/feishu/new", bindIgnErr(forms.NewFeishuHookForm{}), repo.FeishuHooksNewPost) + m.Post("/wechatwork/new", bindIgnErr(forms.NewWechatWorkHookForm{}), repo.WechatworkHooksNewPost) + }) m.Group("/auths", func() { @@ -628,6 +631,7 @@ func RegisterRoutes(m *web.Route) { m.Post("/matrix/new", bindIgnErr(forms.NewMatrixHookForm{}), repo.MatrixHooksNewPost) m.Post("/msteams/new", bindIgnErr(forms.NewMSTeamsHookForm{}), repo.MSTeamsHooksNewPost) m.Post("/feishu/new", bindIgnErr(forms.NewFeishuHookForm{}), repo.FeishuHooksNewPost) + m.Post("/wechatwork/new", bindIgnErr(forms.NewWechatWorkHookForm{}), repo.WechatworkHooksNewPost) m.Get("/{id}", repo.WebHooksEdit) m.Post("/{id}/test", repo.TestWebhook) m.Post("/gitea/{id}", bindIgnErr(forms.NewWebhookForm{}), repo.WebHooksEditPost) @@ -639,6 +643,7 @@ func RegisterRoutes(m *web.Route) { m.Post("/matrix/{id}", bindIgnErr(forms.NewMatrixHookForm{}), repo.MatrixHooksEditPost) m.Post("/msteams/{id}", bindIgnErr(forms.NewMSTeamsHookForm{}), repo.MSTeamsHooksEditPost) m.Post("/feishu/{id}", bindIgnErr(forms.NewFeishuHookForm{}), repo.FeishuHooksEditPost) + m.Post("/wechatwork/{id}", bindIgnErr(forms.NewWechatWorkHookForm{}), repo.WechatworkHooksEditPost) }, webhooksEnabled) m.Group("/keys", func() { diff --git a/services/forms/repo_form.go b/services/forms/repo_form.go index 7c79c4dc2..c1c146f23 100644 --- a/services/forms/repo_form.go +++ b/services/forms/repo_form.go @@ -382,6 +382,18 @@ func (f *NewFeishuHookForm) Validate(req *http.Request, errs binding.Errors) bin return middleware.Validate(errs, ctx.Data, f, ctx.Locale) } +// NewWechatWorkHookForm form for creating wechatwork hook +type NewWechatWorkHookForm struct { + PayloadURL string `binding:"Required;ValidUrl"` + WebhookForm +} + +// Validate validates the fields +func (f *NewWechatWorkHookForm) Validate(req *http.Request, errs binding.Errors) binding.Errors { + ctx := context.GetContext(req) + return middleware.Validate(errs, ctx.Data, f, ctx.Locale) +} + // .___ // | | ______ ________ __ ____ // | |/ ___// ___/ | \_/ __ \ diff --git a/services/webhook/webhook.go b/services/webhook/webhook.go index d094a7754..46002c895 100644 --- a/services/webhook/webhook.go +++ b/services/webhook/webhook.go @@ -52,6 +52,10 @@ var ( name: models.MATRIX, payloadCreator: GetMatrixPayload, }, + models.WECHATWORK: { + name: models.WECHATWORK, + payloadCreator: GetWechatworkPayload, + }, } ) diff --git a/services/webhook/wechatwork.go b/services/webhook/wechatwork.go new file mode 100644 index 000000000..1e2d5f4a1 --- /dev/null +++ b/services/webhook/wechatwork.go @@ -0,0 +1,188 @@ +// Copyright 2021 The Gitea Authors. All rights reserved. +// Use of this source code is governed by a MIT-style +// license that can be found in the LICENSE file. + +package webhook + +import ( + "encoding/json" + "fmt" + "strings" + + "code.gitea.io/gitea/models" + "code.gitea.io/gitea/modules/git" + api "code.gitea.io/gitea/modules/structs" +) + +type ( + // WechatworkPayload represents + WechatworkPayload struct { + Msgtype string `json:"msgtype"` + Text struct { + Content string `json:"content"` + MentionedList []string `json:"mentioned_list"` + MentionedMobileList []string `json:"mentioned_mobile_list"` + } `json:"text"` + Markdown struct { + Content string `json:"content"` + } `json:"markdown"` + } +) + +// SetSecret sets the Wechatwork secret +func (f *WechatworkPayload) SetSecret(_ string) {} + +// JSONPayload Marshals the WechatworkPayload to json +func (f *WechatworkPayload) JSONPayload() ([]byte, error) { + data, err := json.MarshalIndent(f, "", " ") + if err != nil { + return []byte{}, err + } + return data, nil +} + +func newWechatworkMarkdownPayload(title string) *WechatworkPayload { + return &WechatworkPayload{ + Msgtype: "markdown", + Markdown: struct { + Content string `json:"content"` + }{ + Content: title, + }, + } +} + +var ( + _ PayloadConvertor = &WechatworkPayload{} +) + +// Create implements PayloadConvertor Create method +func (f *WechatworkPayload) Create(p *api.CreatePayload) (api.Payloader, error) { + // created tag/branch + refName := git.RefEndName(p.Ref) + title := fmt.Sprintf("[%s] %s %s created", p.Repo.FullName, p.RefType, refName) + + return newWechatworkMarkdownPayload(title), nil +} + +// Delete implements PayloadConvertor Delete method +func (f *WechatworkPayload) Delete(p *api.DeletePayload) (api.Payloader, error) { + // created tag/branch + refName := git.RefEndName(p.Ref) + title := fmt.Sprintf("[%s] %s %s deleted", p.Repo.FullName, p.RefType, refName) + + return newWechatworkMarkdownPayload(title), nil + +} + +// Fork implements PayloadConvertor Fork method +func (f *WechatworkPayload) Fork(p *api.ForkPayload) (api.Payloader, error) { + + title := fmt.Sprintf("%s is forked to %s", p.Forkee.FullName, p.Repo.FullName) + + return newWechatworkMarkdownPayload(title), nil +} + +// Push implements PayloadConvertor Push method +func (f *WechatworkPayload) Push(p *api.PushPayload) (api.Payloader, error) { + var ( + branchName = git.RefEndName(p.Ref) + commitDesc string + ) + + title := fmt.Sprintf("# %s:%s %s ", p.Repo.FullName, branchName, commitDesc) + + var text string + // for each commit, generate attachment text + for i, commit := range p.Commits { + var authorName string + if commit.Author != nil { + authorName = "Author:" + commit.Author.Name + } + + message := strings.ReplaceAll(commit.Message, "\n\n", "\r\n") + text += fmt.Sprintf(" > [%s](%s) \r\n >%s \n >%s", commit.ID[:7], commit.URL, + message, authorName) + + // add linebreak to each commit but the last + if i < len(p.Commits)-1 { + text += "\n" + } + } + return newWechatworkMarkdownPayload(title + "\r\n\r\n" + text), nil + +} + +// Issue implements PayloadConvertor Issue method +func (f *WechatworkPayload) Issue(p *api.IssuePayload) (api.Payloader, error) { + text, issueTitle, attachmentText, _ := getIssuesPayloadInfo(p, noneLinkFormatter, true) + var content string + content += fmt.Sprintf(" >%s\n >%s \n > %s", text, attachmentText, issueTitle) + + return newWechatworkMarkdownPayload(content), nil + +} + +// IssueComment implements PayloadConvertor IssueComment method +func (f *WechatworkPayload) IssueComment(p *api.IssueCommentPayload) (api.Payloader, error) { + text, issueTitle, _ := getIssueCommentPayloadInfo(p, noneLinkFormatter, true) + var content string + content += fmt.Sprintf(" >%s\n >%s \n >%s", text, p.Comment.Body, issueTitle) + + return newWechatworkMarkdownPayload(content), nil + +} + +// PullRequest implements PayloadConvertor PullRequest method +func (f *WechatworkPayload) PullRequest(p *api.PullRequestPayload) (api.Payloader, error) { + text, issueTitle, attachmentText, _ := getPullRequestPayloadInfo(p, noneLinkFormatter, true) + pr := fmt.Sprintf("> %s \r\n > %s \r\n > %s \r\n", + text, issueTitle, attachmentText) + + return newWechatworkMarkdownPayload(pr), nil + +} + +// Review implements PayloadConvertor Review method +func (f *WechatworkPayload) Review(p *api.PullRequestPayload, event models.HookEventType) (api.Payloader, error) { + var text, title string + switch p.Action { + case api.HookIssueSynchronized: + action, err := parseHookPullRequestEventType(event) + if err != nil { + return nil, err + } + title = fmt.Sprintf("[%s] Pull request review %s : #%d %s", p.Repository.FullName, action, p.Index, p.PullRequest.Title) + text = p.Review.Content + } + + return newWechatworkMarkdownPayload("# " + title + "\r\n\r\n >" + text), nil + +} + +// Repository implements PayloadConvertor Repository method +func (f *WechatworkPayload) Repository(p *api.RepositoryPayload) (api.Payloader, error) { + var title string + switch p.Action { + case api.HookRepoCreated: + title = fmt.Sprintf("[%s] Repository created", p.Repository.FullName) + return newWechatworkMarkdownPayload(title), nil + case api.HookRepoDeleted: + title = fmt.Sprintf("[%s] Repository deleted", p.Repository.FullName) + return newWechatworkMarkdownPayload(title), nil + } + + return nil, nil +} + +// Release implements PayloadConvertor Release method +func (f *WechatworkPayload) Release(p *api.ReleasePayload) (api.Payloader, error) { + text, _ := getReleasePayloadInfo(p, noneLinkFormatter, true) + + return newWechatworkMarkdownPayload(text), nil +} + +// GetWechatworkPayload GetWechatworkPayload converts a ding talk webhook into a WechatworkPayload +func GetWechatworkPayload(p api.Payloader, event models.HookEventType, meta string) (api.Payloader, error) { + return convertPayloader(new(WechatworkPayload), p, event) +} diff --git a/templates/admin/hook_new.tmpl b/templates/admin/hook_new.tmpl index 01e9e429a..4710498b2 100644 --- a/templates/admin/hook_new.tmpl +++ b/templates/admin/hook_new.tmpl @@ -32,6 +32,8 @@ {{else if eq .HookType "matrix"}} + {{else if eq .HookType "wechatwork"}} + {{end}} @@ -45,6 +47,7 @@ {{template "repo/settings/webhook/msteams" .}} {{template "repo/settings/webhook/feishu" .}} {{template "repo/settings/webhook/matrix" .}} + {{template "repo/settings/webhook/wechatwork" .}} {{template "repo/settings/webhook/history" .}} diff --git a/templates/org/settings/hook_new.tmpl b/templates/org/settings/hook_new.tmpl index d070b8bc4..43351d0ce 100644 --- a/templates/org/settings/hook_new.tmpl +++ b/templates/org/settings/hook_new.tmpl @@ -27,6 +27,8 @@ {{else if eq .HookType "matrix"}} + {{else if eq .HookType "wechatwork"}} + {{end}} @@ -40,6 +42,7 @@ {{template "repo/settings/webhook/msteams" .}} {{template "repo/settings/webhook/feishu" .}} {{template "repo/settings/webhook/matrix" .}} + {{template "repo/settings/webhook/wechatwork" .}} {{template "repo/settings/webhook/history" .}} diff --git a/templates/repo/settings/webhook/base_list.tmpl b/templates/repo/settings/webhook/base_list.tmpl index e77e74774..e96d08603 100644 --- a/templates/repo/settings/webhook/base_list.tmpl +++ b/templates/repo/settings/webhook/base_list.tmpl @@ -31,6 +31,9 @@ Matrix + + Wechatwork + diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl index 7c2e5b1a9..6df128f40 100644 --- a/templates/repo/settings/webhook/new.tmpl +++ b/templates/repo/settings/webhook/new.tmpl @@ -25,6 +25,8 @@ {{else if eq .HookType "matrix"}} + {{else if eq .HookType "wechatwork"}} + {{end}} @@ -38,6 +40,7 @@ {{template "repo/settings/webhook/msteams" .}} {{template "repo/settings/webhook/feishu" .}} {{template "repo/settings/webhook/matrix" .}} + {{template "repo/settings/webhook/wechatwork" .}} {{template "repo/settings/webhook/history" .}} diff --git a/templates/repo/settings/webhook/wechatwork.tmpl b/templates/repo/settings/webhook/wechatwork.tmpl new file mode 100644 index 000000000..503fab205 --- /dev/null +++ b/templates/repo/settings/webhook/wechatwork.tmpl @@ -0,0 +1,11 @@ +{{if eq .HookType "wechatwork"}} +

{{.i18n.Tr "repo.settings.add_wechatwork_hook_desc" "https://work.weixin.qq.com" | Str2html}}

+
+ {{.CsrfTokenHtml}} +
+ + +
+ {{template "repo/settings/webhook/settings" .}} +
+{{end}} diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl index eeb002cb9..238265fd7 100644 --- a/templates/swagger/v1_json.tmpl +++ b/templates/swagger/v1_json.tmpl @@ -12917,7 +12917,8 @@ "msteams", "slack", "telegram", - "feishu" + "feishu", + "wechatwork" ], "x-go-name": "Type" }