diff --git a/models/fixtures/webhook.yml b/models/fixtures/webhook.yml
index f62bae1f311ce..ebc4062b60ba5 100644
--- a/models/fixtures/webhook.yml
+++ b/models/fixtures/webhook.yml
@@ -22,6 +22,7 @@
content_type: 1 # json
events: '{"push_only":false,"send_everything":false,"choose_events":false,"events":{"create":false,"push":true,"pull_request":true}}'
is_active: true
+
-
id: 4
repo_id: 2
@@ -29,3 +30,23 @@
content_type: 1 # json
events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
is_active: true
+
+-
+ id: 5
+ repo_id: 0
+ owner_id: 0
+ url: www.example.com/url5
+ content_type: 1 # json
+ events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
+ is_active: true
+ is_system_webhook: true
+
+-
+ id: 6
+ repo_id: 0
+ owner_id: 0
+ url: www.example.com/url6
+ content_type: 1 # json
+ events: '{"push_only":true,"branch_filter":"{master,feature*}"}'
+ is_active: true
+ is_system_webhook: false
diff --git a/models/webhook/webhook_system.go b/models/webhook/webhook_system.go
index a2a9ee321ae92..58d9d4a5c1b9d 100644
--- a/models/webhook/webhook_system.go
+++ b/models/webhook/webhook_system.go
@@ -11,6 +11,19 @@ import (
"code.gitea.io/gitea/modules/optional"
)
+// GetSystemOrDefaultWebhooks returns webhooks by given argument or all if argument is missing.
+func GetSystemOrDefaultWebhooks(ctx context.Context, isSystemWebhook optional.Option[bool]) ([]*Webhook, error) {
+ webhooks := make([]*Webhook, 0, 5)
+ if !isSystemWebhook.Has() {
+ return webhooks, db.GetEngine(ctx).Where("repo_id=? AND owner_id=?", 0, 0).
+ Find(&webhooks)
+ }
+
+ return webhooks, db.GetEngine(ctx).
+ Where("repo_id=? AND owner_id=? AND is_system_webhook=?", 0, 0, isSystemWebhook.Value()).
+ Find(&webhooks)
+}
+
// GetDefaultWebhooks returns all admin-default webhooks.
func GetDefaultWebhooks(ctx context.Context) ([]*Webhook, error) {
webhooks := make([]*Webhook, 0, 5)
diff --git a/models/webhook/webhook_system_test.go b/models/webhook/webhook_system_test.go
new file mode 100644
index 0000000000000..96157ed9c9d37
--- /dev/null
+++ b/models/webhook/webhook_system_test.go
@@ -0,0 +1,37 @@
+// Copyright 2017 The Gitea Authors. All rights reserved.
+// SPDX-License-Identifier: MIT
+
+package webhook
+
+import (
+ "testing"
+
+ "code.gitea.io/gitea/models/db"
+ "code.gitea.io/gitea/models/unittest"
+ "code.gitea.io/gitea/modules/optional"
+
+ "github.com/stretchr/testify/assert"
+)
+
+func TestGetSystemOrDefaultWebhooks(t *testing.T) {
+ assert.NoError(t, unittest.PrepareTestDatabase())
+
+ hooks, err := GetSystemOrDefaultWebhooks(db.DefaultContext, optional.None[bool]())
+ assert.NoError(t, err)
+ if assert.Len(t, hooks, 2) {
+ assert.Equal(t, int64(5), hooks[0].ID)
+ assert.Equal(t, int64(6), hooks[1].ID)
+ }
+
+ hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(true))
+ assert.NoError(t, err)
+ if assert.Len(t, hooks, 1) {
+ assert.Equal(t, int64(5), hooks[0].ID)
+ }
+
+ hooks, err = GetSystemOrDefaultWebhooks(db.DefaultContext, optional.Some(false))
+ assert.NoError(t, err)
+ if assert.Len(t, hooks, 1) {
+ assert.Equal(t, int64(6), hooks[0].ID)
+ }
+}
diff --git a/options/locale/locale_cs-CZ.ini b/options/locale/locale_cs-CZ.ini
index ad15d22dd2400..eb0e0dff97256 100644
--- a/options/locale/locale_cs-CZ.ini
+++ b/options/locale/locale_cs-CZ.ini
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Ignorování revizí v .git-blame-ignorerevs.
blame.ignore_revs.failed=Nepodařilo se ignorovat revize v .git-blame-ignore-revs.
user_search_tooltip=Zobrazí maximálně 30 uživatelů
-tree_path_not_found_commit=Cesta %[1]s v commitu %[2]s neexistuje
-tree_path_not_found_branch=Cesta %[1]s ve větvi %[2]s neexistuje
-tree_path_not_found_tag=Cesta %[1]s ve značce %[2]s neexistuje
transfer.accept=Přijmout převod
transfer.accept_desc=Převést do „%s“
diff --git a/options/locale/locale_de-DE.ini b/options/locale/locale_de-DE.ini
index e805f7fe0ac39..120b3ea7db5f0 100644
--- a/options/locale/locale_de-DE.ini
+++ b/options/locale/locale_de-DE.ini
@@ -1111,9 +1111,6 @@ blame.ignore_revs=Revisionen in .git-blame-ignore-revs werden i
blame.ignore_revs.failed=Fehler beim Ignorieren der Revisionen in .git-blame-ignore-revs.
user_search_tooltip=Zeigt maximal 30 Benutzer
-tree_path_not_found_commit=Pfad %[1]s existiert nicht in Commit%[2]s
-tree_path_not_found_branch=Pfad %[1]s existiert nicht in Branch %[2]s
-tree_path_not_found_tag=Pfad %[1]s existiert nicht in Tag %[2]s
transfer.accept=Übertragung Akzeptieren
transfer.accept_desc=`Übertragung nach "%s"`
diff --git a/options/locale/locale_el-GR.ini b/options/locale/locale_el-GR.ini
index 454e57eb128ab..af26256314ba1 100644
--- a/options/locale/locale_el-GR.ini
+++ b/options/locale/locale_el-GR.ini
@@ -992,9 +992,6 @@ blame_prior=Προβολή ευθύνης πριν από αυτή την αλλ
blame.ignore_revs=Αγνόηση των αναθεωρήσεων στο .git-blame-ignore-revs. Πατήστε εδώ για να το παρακάμψετε και να δείτε την κανονική προβολή ευθυνών.
blame.ignore_revs.failed=Αποτυχία αγνόησης των αναθεωρήσεων στο .git-blame-ignore-revs.
-tree_path_not_found_commit=Η διαδρομή %[1]s δεν υπάρχει στην υποβολή %[2]s
-tree_path_not_found_branch=Η διαδρομή %[1]s δεν υπάρχει στον κλάδο %[2]s
-tree_path_not_found_tag=Η διαδρομή %[1]s δεν υπάρχει στην ετικέτα %[2]s
transfer.accept=Αποδοχή Μεταφοράς
transfer.reject=Απόρριψη Μεταφοράς
diff --git a/options/locale/locale_es-ES.ini b/options/locale/locale_es-ES.ini
index 7dd8030d2b0c6..e85e6b3399c1b 100644
--- a/options/locale/locale_es-ES.ini
+++ b/options/locale/locale_es-ES.ini
@@ -982,9 +982,6 @@ blame_prior=Ver la culpa antes de este cambio
blame.ignore_revs=Ignorando revisiones en .git-blame-ignore-revs. Haga clic aquí para saltar y para a la vista normal.
blame.ignore_revs.failed=No se pudieron ignorar las revisiones en .git-blame-ignore-revs.
-tree_path_not_found_commit=La ruta %[1]s no existe en el commit %[2]s
-tree_path_not_found_branch=La ruta %[1]s no existe en la rama %[2]s
-tree_path_not_found_tag=La ruta %[1]s no existe en la etiqueta %[2]s
transfer.accept=Aceptar transferencia
transfer.reject=Rechazar transferencia
diff --git a/options/locale/locale_fr-FR.ini b/options/locale/locale_fr-FR.ini
index a63613cf886aa..e8c621a1fa184 100644
--- a/options/locale/locale_fr-FR.ini
+++ b/options/locale/locale_fr-FR.ini
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Les révisions dans .git-blame-ignore-revs so
blame.ignore_revs.failed=Impossible d'ignorer les révisions dans .git-blame-ignore-revs.
user_search_tooltip=Affiche un maximum de 30 utilisateurs
-tree_path_not_found_commit=Le chemin %[1]s n’existe pas dans la révision %[2]s.
-tree_path_not_found_branch=Le chemin %[1]s n’existe pas dans la branche %[2]s.
-tree_path_not_found_tag=Le chemin %[1]s n’existe pas dans l’étiquette %[2]s.
transfer.accept=Accepter le transfert
transfer.accept_desc=Transférer à « %s »
diff --git a/options/locale/locale_ga-IE.ini b/options/locale/locale_ga-IE.ini
index ef486b9e7a703..51c3ab20cc804 100644
--- a/options/locale/locale_ga-IE.ini
+++ b/options/locale/locale_ga-IE.ini
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Ag déanamh neamhairde de leasuithe i .git-blame-
blame.ignore_revs.failed=Theip ar neamhaird a dhéanamh ar leasuithe i .git-blame-ignore-revs.
user_search_tooltip=Taispeáint uasmhéid de 30 úsáideoir
-tree_path_not_found_commit=Níl cosán %[1]s ann i dtiomantas %[2]s
-tree_path_not_found_branch=Níl cosán %[1]s ann i mbrainse %[2]s
-tree_path_not_found_tag=Níl cosán %[1]s ann i gclib %[2]s
transfer.accept=Glac le hAistriú
transfer.accept_desc=Aistriú chuig “%s”
diff --git a/options/locale/locale_ja-JP.ini b/options/locale/locale_ja-JP.ini
index e5f3d14115177..7e39db8353842 100644
--- a/options/locale/locale_ja-JP.ini
+++ b/options/locale/locale_ja-JP.ini
@@ -1109,9 +1109,6 @@ blame_prior=この変更より前のBlameを表示
blame.ignore_revs=.git-blame-ignore-revs で指定されたリビジョンは除外しています。 これを迂回して通常のBlame表示を見るには ここをクリック。
blame.ignore_revs.failed=.git-blame-ignore-revs によるリビジョンの無視は失敗しました。
-tree_path_not_found_commit=パス %[1]s はコミット %[2]s に存在しません
-tree_path_not_found_branch=パス %[1]s はブランチ %[2]s に存在しません
-tree_path_not_found_tag=パス %[1]s はタグ %[2]s に存在しません
transfer.accept=移転を承認
transfer.accept_desc=`"%s" に移転`
diff --git a/options/locale/locale_lv-LV.ini b/options/locale/locale_lv-LV.ini
index c90de9578b6e2..8e1c4a651cacf 100644
--- a/options/locale/locale_lv-LV.ini
+++ b/options/locale/locale_lv-LV.ini
@@ -997,9 +997,6 @@ blame_prior=Aplūkot vainīgo par izmaiņām pirms šīs revīzijas
blame.ignore_revs=Neņem vērā izmaiņas no .git-blame-ignore-revs. Nospiediet šeit, lai to apietu un redzētu visu izmaiņu skatu.
blame.ignore_revs.failed=Neizdevās neņemt vērā izmaiņas no .git-blam-ignore-revs.
-tree_path_not_found_commit=Revīzijā %[2]s neeksistē ceļš %[1]s
-tree_path_not_found_branch=Atzarā %[2]s nepastāv ceļš %[1]s
-tree_path_not_found_tag=Tagā %[2]s nepastāv ceļš %[1]s
transfer.accept=Apstiprināt īpašnieka maiņu
transfer.reject=Noraidīt īpašnieka maiņu
diff --git a/options/locale/locale_pt-PT.ini b/options/locale/locale_pt-PT.ini
index 7b57e776d12d2..a0d0201a37cee 100644
--- a/options/locale/locale_pt-PT.ini
+++ b/options/locale/locale_pt-PT.ini
@@ -1115,9 +1115,6 @@ blame.ignore_revs=Ignorando as revisões em .git-blame-ignore-revs<
blame.ignore_revs.failed=Falhou ao ignorar as revisões em .git-blame-ignore-revs.
user_search_tooltip=Mostra um máximo de 30 utilizadores
-tree_path_not_found_commit=A localização %[1]s não existe no cometimento %[2]s
-tree_path_not_found_branch=A localização %[1]s não existe no ramo %[2]s
-tree_path_not_found_tag=A localização %[1]s não existe na etiqueta %[2]s
transfer.accept=Aceitar transferência
transfer.accept_desc=`Transferir para "%s"`
diff --git a/options/locale/locale_ru-RU.ini b/options/locale/locale_ru-RU.ini
index 9c6c706288b86..17ebb275a3c7a 100644
--- a/options/locale/locale_ru-RU.ini
+++ b/options/locale/locale_ru-RU.ini
@@ -978,8 +978,6 @@ delete_preexisting_content=Удалить файлы из %s
delete_preexisting_success=Удалены непринятые файлы в %s
blame_prior=Показать авторство предшествующих изменений
-tree_path_not_found_commit=Путь %[1]s не существует в коммите %[2]s
-tree_path_not_found_branch=Путь %[1]s не существует в ветке %[2]s
transfer.accept=Принять трансфер
transfer.reject=Отказаться от перемещения
diff --git a/options/locale/locale_tr-TR.ini b/options/locale/locale_tr-TR.ini
index e939d9f04ea0a..8840b45a066cd 100644
--- a/options/locale/locale_tr-TR.ini
+++ b/options/locale/locale_tr-TR.ini
@@ -1083,9 +1083,6 @@ blame_prior=Bu değişiklikten önceki suçu görüntüle
blame.ignore_revs=.git-blame-ignore-revs dosyasındaki sürümler yok sayılıyor. Bunun yerine normal sorumlu görüntüsü için buraya tıklayın.
blame.ignore_revs.failed=.git-blame-ignore-revs dosyasındaki sürümler yok sayılamadı.
-tree_path_not_found_commit=%[1] yolu, %[2]s işlemesinde mevcut değil
-tree_path_not_found_branch=%[1] yolu, %[2]s dalında mevcut değil
-tree_path_not_found_tag=%[1] yolu, %[2]s etiketinde mevcut değil
transfer.accept=Aktarımı Kabul Et
transfer.reject=Aktarımı Reddet
diff --git a/options/locale/locale_zh-CN.ini b/options/locale/locale_zh-CN.ini
index 564e9f9d8df1a..3215ea9045923 100644
--- a/options/locale/locale_zh-CN.ini
+++ b/options/locale/locale_zh-CN.ini
@@ -1111,9 +1111,6 @@ blame.ignore_revs=忽略 .git-blame-ignore-revs 的修订。点
blame.ignore_revs.failed=忽略 .git-blame-ignore-revs 版本失败。
user_search_tooltip=最多显示30名用户
-tree_path_not_found_commit=路径%[1]s 在提交 %[2]s 中不存在
-tree_path_not_found_branch=路径 %[1]s 不存在于分支 %[2]s 中。
-tree_path_not_found_tag=路径 %[1]s 不存在于标签 %[2]s 中
transfer.accept=接受转移
transfer.accept_desc=`转移到 "%s"`
diff --git a/options/locale/locale_zh-TW.ini b/options/locale/locale_zh-TW.ini
index b4183aa70a07f..eafe060ff4433 100644
--- a/options/locale/locale_zh-TW.ini
+++ b/options/locale/locale_zh-TW.ini
@@ -1108,9 +1108,6 @@ blame.ignore_revs=忽略 .git-blame-ignore-revs 中的修訂。
blame.ignore_revs.failed=忽略 .git-blame-ignore-revs 中的修訂失敗。
user_search_tooltip=顯示最多 30 個使用者
-tree_path_not_found_commit=路徑 %[1]s 在提交 %[2]s 中不存在
-tree_path_not_found_branch=路徑 %[1]s 在分支 %[2]s 中不存在
-tree_path_not_found_tag=路徑 %[1]s 在標籤 %[2]s 中不存在
transfer.accept=同意轉移
transfer.accept_desc=轉移到「%s」
diff --git a/package-lock.json b/package-lock.json
index 1e3c5ab155d47..89bffd0ff345f 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -67,7 +67,6 @@
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
"@playwright/test": "1.49.1",
- "@silverwind/vue-tsc": "2.1.13",
"@stoplight/spectral-cli": "6.14.2",
"@stylistic/eslint-plugin-js": "2.12.1",
"@stylistic/stylelint-plugin": "3.1.1",
@@ -112,7 +111,8 @@
"type-fest": "4.30.2",
"updates": "16.4.1",
"vite-string-plugin": "1.3.4",
- "vitest": "2.1.8"
+ "vitest": "2.1.8",
+ "vue-tsc": "2.2.0"
},
"engines": {
"node": ">= 18.0.0"
@@ -3643,24 +3643,6 @@
"hasInstallScript": true,
"license": "Apache-2.0"
},
- "node_modules/@silverwind/vue-tsc": {
- "version": "2.1.13",
- "resolved": "https://registry.npmjs.org/@silverwind/vue-tsc/-/vue-tsc-2.1.13.tgz",
- "integrity": "sha512-ejFxz1KZiUGAESbC+eURnjqt0N95qkU9eZU7W15wgF9zV+v2FEu3ZLduuXTC7D/Sg6lL1R/QjPfUbxbAbBQOsw==",
- "dev": true,
- "license": "MIT",
- "dependencies": {
- "@volar/typescript": "~2.4.11",
- "@vue/language-core": "2.1.10",
- "semver": "^7.5.4"
- },
- "bin": {
- "vue-tsc": "bin/vue-tsc.js"
- },
- "peerDependencies": {
- "typescript": ">=5.0.0"
- }
- },
"node_modules/@silverwind/vue3-calendar-heatmap": {
"version": "2.0.6",
"resolved": "https://registry.npmjs.org/@silverwind/vue3-calendar-heatmap/-/vue3-calendar-heatmap-2.0.6.tgz",
@@ -5251,17 +5233,17 @@
}
},
"node_modules/@vue/language-core": {
- "version": "2.1.10",
- "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-2.1.10.tgz",
- "integrity": "sha512-DAI289d0K3AB5TUG3xDp9OuQ71CnrujQwJrQnfuZDwo6eGNf0UoRlPuaVNO+Zrn65PC3j0oB2i7mNmVPggeGeQ==",
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/@vue/language-core/-/language-core-2.2.0.tgz",
+ "integrity": "sha512-O1ZZFaaBGkKbsRfnVH1ifOK1/1BUkyK+3SQsfnh6PmMmD4qJcTU8godCeA96jjDRTL6zgnK7YzCHfaUlH2r0Mw==",
"dev": true,
"license": "MIT",
"dependencies": {
- "@volar/language-core": "~2.4.8",
+ "@volar/language-core": "~2.4.11",
"@vue/compiler-dom": "^3.5.0",
"@vue/compiler-vue2": "^2.7.16",
"@vue/shared": "^3.5.0",
- "alien-signals": "^0.2.0",
+ "alien-signals": "^0.4.9",
"minimatch": "^9.0.3",
"muggle-string": "^0.4.1",
"path-browserify": "^1.0.1"
@@ -5664,9 +5646,9 @@
}
},
"node_modules/alien-signals": {
- "version": "0.2.2",
- "resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-0.2.2.tgz",
- "integrity": "sha512-cZIRkbERILsBOXTQmMrxc9hgpxglstn69zm+F1ARf4aPAzdAFYd6sBq87ErO0Fj3DV94tglcyHG5kQz9nDC/8A==",
+ "version": "0.4.14",
+ "resolved": "https://registry.npmjs.org/alien-signals/-/alien-signals-0.4.14.tgz",
+ "integrity": "sha512-itUAVzhczTmP2U5yX67xVpsbbOiquusbWVyA9N+sy6+r6YVbFkahXvNCeEPWEOMhwDYwbVbGHFkVL03N9I5g+Q==",
"dev": true,
"license": "MIT"
},
@@ -14526,6 +14508,23 @@
}
}
},
+ "node_modules/vue-tsc": {
+ "version": "2.2.0",
+ "resolved": "https://registry.npmjs.org/vue-tsc/-/vue-tsc-2.2.0.tgz",
+ "integrity": "sha512-gtmM1sUuJ8aSb0KoAFmK9yMxb8TxjewmxqTJ1aKphD5Cbu0rULFY6+UQT51zW7SpUcenfPUuflKyVwyx9Qdnxg==",
+ "dev": true,
+ "license": "MIT",
+ "dependencies": {
+ "@volar/typescript": "~2.4.11",
+ "@vue/language-core": "2.2.0"
+ },
+ "bin": {
+ "vue-tsc": "bin/vue-tsc.js"
+ },
+ "peerDependencies": {
+ "typescript": ">=5.0.0"
+ }
+ },
"node_modules/watchpack": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/watchpack/-/watchpack-2.4.2.tgz",
diff --git a/package.json b/package.json
index 6881ddb306ce6..31a65c647c103 100644
--- a/package.json
+++ b/package.json
@@ -66,7 +66,6 @@
"devDependencies": {
"@eslint-community/eslint-plugin-eslint-comments": "4.4.1",
"@playwright/test": "1.49.1",
- "@silverwind/vue-tsc": "2.1.13",
"@stoplight/spectral-cli": "6.14.2",
"@stylistic/eslint-plugin-js": "2.12.1",
"@stylistic/stylelint-plugin": "3.1.1",
@@ -111,7 +110,8 @@
"type-fest": "4.30.2",
"updates": "16.4.1",
"vite-string-plugin": "1.3.4",
- "vitest": "2.1.8"
+ "vitest": "2.1.8",
+ "vue-tsc": "2.2.0"
},
"browserslist": [
"defaults"
diff --git a/routers/api/v1/admin/hooks.go b/routers/api/v1/admin/hooks.go
index 6b4689047b5fe..c812ca182d502 100644
--- a/routers/api/v1/admin/hooks.go
+++ b/routers/api/v1/admin/hooks.go
@@ -34,11 +34,30 @@ func ListHooks(ctx *context.APIContext) {
// in: query
// description: page size of results
// type: integer
+ // - type: string
+ // enum:
+ // - system
+ // - default
+ // - all
+ // description: system, default or both kinds of webhooks
+ // name: type
+ // default: system
+ // in: query
+ //
// responses:
// "200":
// "$ref": "#/responses/HookList"
- sysHooks, err := webhook.GetSystemWebhooks(ctx, optional.None[bool]())
+ // for compatibility the default value is true
+ isSystemWebhook := optional.Some(true)
+ typeValue := ctx.FormString("type")
+ if typeValue == "default" {
+ isSystemWebhook = optional.Some(false)
+ } else if typeValue == "all" {
+ isSystemWebhook = optional.None[bool]()
+ }
+
+ sysHooks, err := webhook.GetSystemOrDefaultWebhooks(ctx, isSystemWebhook)
if err != nil {
ctx.Error(http.StatusInternalServerError, "GetSystemWebhooks", err)
return
diff --git a/templates/swagger/v1_json.tmpl b/templates/swagger/v1_json.tmpl
index fb37d45ce8de2..8082fc594ac02 100644
--- a/templates/swagger/v1_json.tmpl
+++ b/templates/swagger/v1_json.tmpl
@@ -234,6 +234,18 @@
"description": "page size of results",
"name": "limit",
"in": "query"
+ },
+ {
+ "enum": [
+ "system",
+ "default",
+ "all"
+ ],
+ "type": "string",
+ "default": "system",
+ "description": "system, default or both kinds of webhooks",
+ "name": "type",
+ "in": "query"
}
],
"responses": {