@@ -6,6 +6,7 @@ package utils
6
6
import (
7
7
"fmt"
8
8
"net/http"
9
+ "strconv"
9
10
"strings"
10
11
11
12
"code.gitea.io/gitea/models/db"
@@ -164,13 +165,20 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI
164
165
if len (form .Events ) == 0 {
165
166
form .Events = []string {"push" }
166
167
}
168
+
169
+ isSystemWebhook , err := strconv .ParseBool (form .Config ["is_system_webhook" ])
170
+ if err != nil {
171
+ ctx .Error (http .StatusUnprocessableEntity , "" , "Invalid is_system_webhook value" )
172
+ return nil , false
173
+ }
167
174
w := & webhook.Webhook {
168
- OwnerID : ownerID ,
169
- RepoID : repoID ,
170
- URL : form .Config ["url" ],
171
- ContentType : webhook .ToHookContentType (form .Config ["content_type" ]),
172
- Secret : form .Config ["secret" ],
173
- HTTPMethod : "POST" ,
175
+ OwnerID : ownerID ,
176
+ RepoID : repoID ,
177
+ URL : form .Config ["url" ],
178
+ ContentType : webhook .ToHookContentType (form .Config ["content_type" ]),
179
+ Secret : form .Config ["secret" ],
180
+ HTTPMethod : "POST" ,
181
+ IsSystemWebhook : isSystemWebhook ,
174
182
HookEvent : & webhook_module.HookEvent {
175
183
ChooseEvents : true ,
176
184
HookEvents : webhook_module.HookEvents {
@@ -200,7 +208,7 @@ func addHook(ctx *context.APIContext, form *api.CreateHookOption, ownerID, repoI
200
208
IsActive : form .Active ,
201
209
Type : form .Type ,
202
210
}
203
- err : = w .SetHeaderAuthorization (form .AuthorizationHeader )
211
+ err = w .SetHeaderAuthorization (form .AuthorizationHeader )
204
212
if err != nil {
205
213
ctx .Error (http .StatusInternalServerError , "SetHeaderAuthorization" , err )
206
214
return nil , false
0 commit comments