summaryrefslogtreecommitdiffstats
path: root/models/webhook
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2022-06-06 16:01:49 +0800
committerGitHub <noreply@github.com>2022-06-06 16:01:49 +0800
commit26095115f4ae90e3fdc6ab695978efd16e317f75 (patch)
tree92ec1c7ff54e0a65f4f0662baa8c0244dd9f324b /models/webhook
parentebeb6e7c71a0c763b52153f4eb427e7c5b89a95e (diff)
downloadgitea-26095115f4ae90e3fdc6ab695978efd16e317f75.tar.gz
gitea-26095115f4ae90e3fdc6ab695978efd16e317f75.zip
Move some repository related code into sub package (#19711)
* Move some repository related code into sub package * Move more repository functions out of models * Fix lint * Some performance optimization for webhooks and others * some refactors * Fix lint * Fix * Update modules/repository/delete.go Co-authored-by: delvh <dev.lh@web.de> * Fix test * Merge * Fix test * Fix test * Fix test * Fix test Co-authored-by: delvh <dev.lh@web.de>
Diffstat (limited to 'models/webhook')
-rw-r--r--models/webhook/webhook.go8
1 files changed, 8 insertions, 0 deletions
diff --git a/models/webhook/webhook.go b/models/webhook/webhook.go
index 5eea977725..1b79a414ad 100644
--- a/models/webhook/webhook.go
+++ b/models/webhook/webhook.go
@@ -397,6 +397,14 @@ func CreateWebhook(ctx context.Context, w *Webhook) error {
return db.Insert(ctx, w)
}
+// CreateWebhooks creates multiple web hooks
+func CreateWebhooks(ctx context.Context, ws []*Webhook) error {
+ for i := 0; i < len(ws); i++ {
+ ws[i].Type = strings.TrimSpace(ws[i].Type)
+ }
+ return db.Insert(ctx, ws)
+}
+
// getWebhook uses argument bean as query condition,
// ID must be specified and do not assign unnecessary fields.
func getWebhook(bean *Webhook) (*Webhook, error) {