feat: add webhook edit UI and signing secret status indicator (#6027)

This commit is contained in:
Yiges.M.x.
2026-06-25 22:26:20 +08:00
committed by GitHub
parent 9e84f61029
commit c703b05dab
10 changed files with 147 additions and 57 deletions
+8 -6
View File
@@ -1271,9 +1271,10 @@ func generateUserWebhookID() string {
// convertUserWebhookFromUserSetting converts a storepb webhook to a v1pb UserWebhook.
func convertUserWebhookFromUserSetting(webhook *storepb.WebhooksUserSetting_Webhook, user *store.User) *v1pb.UserWebhook {
return &v1pb.UserWebhook{
Name: fmt.Sprintf("%s/webhooks/%s", BuildUserName(user.Username), webhook.Id),
Url: webhook.Url,
DisplayName: webhook.Title,
Name: fmt.Sprintf("%s/webhooks/%s", BuildUserName(user.Username), webhook.Id),
Url: webhook.Url,
DisplayName: webhook.Title,
HasSigningSecret: webhook.SigningSecret != "",
// Note: create_time and update_time are not available in the user setting webhook structure
// This is a limitation of storing webhooks in user settings vs the dedicated webhook table
}
@@ -1470,9 +1471,10 @@ func convertUserSettingFromStore(storeSetting *storepb.UserSetting, user *store.
apiWebhooks = make([]*v1pb.UserWebhook, 0, len(webhooks.Webhooks))
for _, webhook := range webhooks.Webhooks {
apiWebhook := &v1pb.UserWebhook{
Name: fmt.Sprintf("%s/webhooks/%s", BuildUserName(user.Username), webhook.Id),
Url: webhook.Url,
DisplayName: webhook.Title,
Name: fmt.Sprintf("%s/webhooks/%s", BuildUserName(user.Username), webhook.Id),
Url: webhook.Url,
DisplayName: webhook.Title,
HasSigningSecret: webhook.SigningSecret != "",
}
apiWebhooks = append(apiWebhooks, apiWebhook)
}
@@ -26,4 +26,5 @@ func TestConvertUserWebhookFromUserSettingOmitsSigningSecret(t *testing.T) {
require.Equal(t, "My Webhook", apiWebhook.DisplayName)
require.Equal(t, "https://example.com/postreceive", apiWebhook.Url)
require.Empty(t, apiWebhook.SigningSecret, "signing secret must never be returned in API responses")
require.True(t, apiWebhook.HasSigningSecret, "has_signing_secret must be true when secret is configured")
}