From 828a27feeb11474b848be183a8fce2d036dec3cc Mon Sep 17 00:00:00 2001 From: S7evinK Date: Sat, 28 Mar 2020 14:09:55 +0100 Subject: Add Matrix webhook (#10831) * Add Matrix webhook Signed-off-by: Till Faelligen * Add template and related translations for Matrix hook Signed-off-by: Till Faelligen * Add actual webhook routes and form Signed-off-by: Till Faelligen * Add missing file Signed-off-by: Till Faelligen * Update modules/webhook/matrix_test.go * Use stricter regex to replace URLs Signed-off-by: Till Faelligen * Escape url and text Signed-off-by: Till Faelligen * Remove unnecessary whitespace * Fix copy and paste mistake Co-Authored-By: Tulir Asokan * Fix indention inconsistency * Use Authorization header instead of url parameter * Add raw commit information to webhook Co-authored-by: Lauris BH Co-authored-by: Tulir Asokan --- modules/auth/repo_form.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'modules/auth') diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go index 123090dbb7..80ed314196 100644 --- a/modules/auth/repo_form.go +++ b/modules/auth/repo_form.go @@ -313,6 +313,20 @@ func (f *NewTelegramHookForm) Validate(ctx *macaron.Context, errs binding.Errors return validate(errs, ctx.Data, f, ctx.Locale) } +// NewMatrixHookForm form for creating Matrix hook +type NewMatrixHookForm struct { + HomeserverURL string `binding:"Required;ValidUrl"` + RoomID string `binding:"Required"` + AccessToken string `binding:"Required"` + MessageType int + WebhookForm +} + +// Validate validates the fields +func (f *NewMatrixHookForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors { + return validate(errs, ctx.Data, f, ctx.Locale) +} + // NewMSTeamsHookForm form for creating MS Teams hook type NewMSTeamsHookForm struct { PayloadURL string `binding:"Required;ValidUrl"` -- cgit v1.2.3