summaryrefslogtreecommitdiffstats
path: root/templates
diff options
context:
space:
mode:
authorS7evinK <tfaelligen@gmail.com>2020-03-28 14:09:55 +0100
committerGitHub <noreply@github.com>2020-03-28 15:09:55 +0200
commit828a27feeb11474b848be183a8fce2d036dec3cc (patch)
tree5182b9bfdb34b9e8f4cc4e61d956ed425a334e9a /templates
parent7cd47046ea6e1fde2c88290a42f345795aee0ea4 (diff)
downloadgitea-828a27feeb11474b848be183a8fce2d036dec3cc.tar.gz
gitea-828a27feeb11474b848be183a8fce2d036dec3cc.zip
Add Matrix webhook (#10831)
* Add Matrix webhook Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Add template and related translations for Matrix hook Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Add actual webhook routes and form Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Add missing file Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Update modules/webhook/matrix_test.go * Use stricter regex to replace URLs Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Escape url and text Signed-off-by: Till Faelligen <tfaelligen@gmail.com> * Remove unnecessary whitespace * Fix copy and paste mistake Co-Authored-By: Tulir Asokan <tulir@maunium.net> * Fix indention inconsistency * Use Authorization header instead of url parameter * Add raw commit information to webhook Co-authored-by: Lauris BH <lauris@nix.lv> Co-authored-by: Tulir Asokan <tulir@maunium.net>
Diffstat (limited to 'templates')
-rw-r--r--templates/repo/settings/webhook/list.tmpl3
-rw-r--r--templates/repo/settings/webhook/matrix.tmpl31
-rw-r--r--templates/repo/settings/webhook/new.tmpl3
3 files changed, 37 insertions, 0 deletions
diff --git a/templates/repo/settings/webhook/list.tmpl b/templates/repo/settings/webhook/list.tmpl
index 0bdc95fa39..417d16ce30 100644
--- a/templates/repo/settings/webhook/list.tmpl
+++ b/templates/repo/settings/webhook/list.tmpl
@@ -29,6 +29,9 @@
<a class="item" href="{{.BaseLink}}/feishu/new">
<img class="img-10" src="{{StaticUrlPrefix}}/img/feishu.png">Feishu
</a>
+ <a class="item" href="{{.BaseLink}}/matrix/new">
+ <img class="img-10" src="{{StaticUrlPrefix}}/img/matrix.svg">Matrix
+ </a>
</div>
</div>
</div>
diff --git a/templates/repo/settings/webhook/matrix.tmpl b/templates/repo/settings/webhook/matrix.tmpl
new file mode 100644
index 0000000000..032537dffc
--- /dev/null
+++ b/templates/repo/settings/webhook/matrix.tmpl
@@ -0,0 +1,31 @@
+{{if eq .HookType "matrix"}}
+ <p>{{.i18n.Tr "repo.settings.add_matrix_hook_desc" "https://matrix.org/" | Str2html}}</p>
+ <form class="ui form" action="{{.BaseLink}}/matrix/{{or .Webhook.ID "new"}}" method="post">
+ {{.CsrfTokenHtml}}
+ <div class="required field {{if .Err_HomeserverURL}}error{{end}}">
+ <label for="homeserver_url">{{.i18n.Tr "repo.settings.matrix.homeserver_url"}}</label>
+ <input id="homeserver_url" name="homeserver_url" type="text" value="{{.MatrixHook.HomeserverURL}}" autofocus required>
+ </div>
+ <div class="required field {{if .Err_Room}}error{{end}}">
+ <label for="room_id">{{.i18n.Tr "repo.settings.matrix.room_id"}}</label>
+ <input id="room_id" name="room_id" type="text" value="{{.MatrixHook.Room}}" required>
+ </div>
+ <div class="required field {{if .Err_AccessToken}}error{{end}}">
+ <label for="access_token">{{.i18n.Tr "repo.settings.matrix.access_token"}}</label>
+ <input id="access_token" name="access_token" type="text" value="{{.MatrixHook.AccessToken}}" required>
+ </div>
+ <div class="field">
+ <label>{{.i18n.Tr "repo.settings.matrix.message_type"}}</label>
+ <div class="ui selection dropdown">
+ <input type="hidden" id="message_type" name="message_type" value="{{if .MatrixHook.MessageType}}{{.MatrixHook.MessageType}}{{else}}1{{end}}">
+ <div class="default text"></div>
+ <i class="dropdown icon"></i>
+ <div class="menu">
+ <div class="item" data-value="1">m.notice</div>
+ <div class="item" data-value="2">m.text</div>
+ </div>
+ </div>
+ </div>
+ {{template "repo/settings/webhook/settings" .}}
+ </form>
+{{end}}
diff --git a/templates/repo/settings/webhook/new.tmpl b/templates/repo/settings/webhook/new.tmpl
index d02da057f2..cf4c541bb0 100644
--- a/templates/repo/settings/webhook/new.tmpl
+++ b/templates/repo/settings/webhook/new.tmpl
@@ -23,6 +23,8 @@
<img class="img-13" src="{{StaticUrlPrefix}}/img/msteams.png">
{{else if eq .HookType "feishu"}}
<img class="img-13" src="{{StaticUrlPrefix}}/img/feishu.png">
+ {{else if eq .HookType "matrix"}}
+ <img class="img-13" src="{{StaticUrlPrefix}}/img/matrix.svg">
{{end}}
</div>
</h4>
@@ -35,6 +37,7 @@
{{template "repo/settings/webhook/telegram" .}}
{{template "repo/settings/webhook/msteams" .}}
{{template "repo/settings/webhook/feishu" .}}
+ {{template "repo/settings/webhook/matrix" .}}
</div>
{{template "repo/settings/webhook/history" .}}