Signed-off-by: Anirudh Oppiliappan anirudh@tangled.org
appview/repo/router.go
appview/repo/router.go
This file has not been changed.
appview/repo/settings.go
appview/repo/settings.go
This file has not been changed.
+7
-20
appview/repo/webhooks.go
+7
-20
appview/repo/webhooks.go
···
1
package repo
2
3
import (
4
-
"crypto/rand"
5
-
"encoding/hex"
6
"net/http"
7
"strconv"
8
"strings"
···
57
return
58
}
59
60
-
// Validate URL
61
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
62
rp.pages.Notice(w, "webhooks-error", "Webhook URL must start with http:// or https://")
63
return
64
}
65
66
secret := strings.TrimSpace(r.FormValue("secret"))
67
-
if secret == "" {
68
-
// Generate a random secret if not provided
69
-
secretBytes := make([]byte, 32)
70
-
if _, err := rand.Read(secretBytes); err != nil {
71
-
l.Error("failed to generate secret", "err", err)
72
-
rp.pages.Notice(w, "webhooks-error", "Failed to generate secret")
73
-
return
74
-
}
75
-
secret = hex.EncodeToString(secretBytes)
76
-
}
77
78
active := r.FormValue("active") == "on"
79
80
-
// Parse events - only push events are supported for now
81
events := []string{}
82
if r.FormValue("event_push") == "on" {
83
-
events = append(events, "push")
84
}
85
86
if len(events) == 0 {
···
116
return
117
}
118
119
-
rp.pages.HxLocation(w, "/"+f.Did+"/"+f.Name+"/settings?tab=hooks")
120
}
121
122
// UpdateWebhook updates an existing webhook
···
171
// Parse events - only push events are supported for now
172
events := []string{}
173
if r.FormValue("event_push") == "on" {
174
-
events = append(events, "push")
175
}
176
177
if len(events) > 0 {
···
198
return
199
}
200
201
-
rp.pages.Notice(w, "webhooks-success", "Webhook updated successfully")
202
}
203
204
// DeleteWebhook deletes a webhook
···
254
return
255
}
256
257
-
rp.pages.HxLocation(w, "/"+f.Did+"/"+f.Name+"/settings?tab=hooks")
258
}
259
260
// ToggleWebhook toggles the active state of a webhook
···
313
return
314
}
315
316
-
rp.pages.HxLocation(w, "/"+f.Did+"/"+f.Name+"/settings?tab=hooks")
317
}
···
1
package repo
2
3
import (
4
"net/http"
5
"strconv"
6
"strings"
···
55
return
56
}
57
58
if !strings.HasPrefix(url, "http://") && !strings.HasPrefix(url, "https://") {
59
rp.pages.Notice(w, "webhooks-error", "Webhook URL must start with http:// or https://")
60
return
61
}
62
63
secret := strings.TrimSpace(r.FormValue("secret"))
64
+
// if secret is empty, we don't sign
65
66
active := r.FormValue("active") == "on"
67
68
events := []string{}
69
if r.FormValue("event_push") == "on" {
70
+
events = append(events, string(models.WebhookEventPush))
71
}
72
73
if len(events) == 0 {
···
103
return
104
}
105
106
+
rp.pages.HxRefresh(w)
107
}
108
109
// UpdateWebhook updates an existing webhook
···
158
// Parse events - only push events are supported for now
159
events := []string{}
160
if r.FormValue("event_push") == "on" {
161
+
events = append(events, string(models.WebhookEventPush))
162
}
163
164
if len(events) > 0 {
···
185
return
186
}
187
188
+
rp.pages.HxRefresh(w)
189
}
190
191
// DeleteWebhook deletes a webhook
···
241
return
242
}
243
244
+
rp.pages.HxRefresh(w)
245
}
246
247
// ToggleWebhook toggles the active state of a webhook
···
300
return
301
}
302
303
+
rp.pages.HxRefresh(w)
304
}
History
6 rounds
1 comment
anirudh.fi
submitted
#5
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
pull request successfully merged
anirudh.fi
submitted
#4
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
anirudh.fi
submitted
#3
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
anirudh.fi
submitted
#2
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 0 comments
anirudh.fi
submitted
#1
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
2/3 failed, 1/3 success
expand
collapse
expand 1 comment
anirudh.fi
submitted
#0
1 commit
expand
collapse
appview/repo: add webhook management endpoints
Signed-off-by: Anirudh Oppiliappan <anirudh@tangled.org>
changeset lgtm otherwise!