Skip to content

Commit 0c8f842

Browse files
authored
Merge pull request #177 from linuxfoundation/feat/LFXV2-3094-chat-webhook-url
[LFXV2-3094] feat(committee): add chat_webhook_url field to Committee domain model
2 parents 1237a33 + 0385b3b commit 0c8f842

15 files changed

Lines changed: 231 additions & 17 deletions

File tree

cmd/committee-api/design/committee.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ var _ = dsl.Service("committee-service", func() {
3535
CommitteeBaseAttributes()
3636

3737
CommitteeSettingsAttributes()
38+
ChatWebhookURLAttribute()
3839

3940
WritersAttribute()
4041
AuditorsAttribute()
@@ -228,6 +229,7 @@ var _ = dsl.Service("committee-service", func() {
228229

229230
CommitteeUIDAttribute()
230231
CommitteeSettingsAttributes()
232+
ChatWebhookURLAttribute()
231233

232234
WritersAttribute()
233235
AuditorsAttribute()

cmd/committee-api/design/type.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,12 @@ func DescriptionAttribute() {
208208
// would otherwise pass dsl.FormatURI as syntactically valid URIs.
209209
const urlPattern = `^https?://[^\s/$.?#][^\s]*$`
210210

211+
// httpsURLPattern validates an HTTPS-only URL or an empty string.
212+
// Used for write-only credential fields (e.g. webhook URLs) where:
213+
// - a non-empty value must be a valid HTTPS URL (plaintext HTTP is rejected)
214+
// - an empty string is the explicit clear signal (see ChatWebhookURLAttribute)
215+
const httpsURLPattern = `^$|^https://[^\s/$.?#][^\s]*$`
216+
211217
// WebsiteAttribute is the DSL attribute for committee website.
212218
func WebsiteAttribute() {
213219
dsl.Attribute("website", dsl.String, "The website URL of the committee", func() {
@@ -1028,6 +1034,17 @@ func ChatChannelAttribute() {
10281034
})
10291035
}
10301036

1037+
// ChatWebhookURLAttribute is the DSL attribute for the committee's Slack Incoming Webhook URL.
1038+
// This field is write-only: accepted on create and PUT settings, never returned from GET.
1039+
// Update semantics: omit or send null to preserve the stored URL; send "" to clear it.
1040+
func ChatWebhookURLAttribute() {
1041+
dsl.Attribute("chat_webhook_url", dsl.String, "Slack Incoming Webhook URL for sharing content to a Slack channel. Write-only: never returned from GET. Send empty string to clear a previously stored value; omit the field (or send null) to preserve the existing value.", func() {
1042+
dsl.Pattern(httpsURLPattern)
1043+
dsl.MaxLength(500)
1044+
dsl.Example("https://hooks.slack.example.org/services/TXXXXXXXX/BXXXXXXXX/placeholder")
1045+
})
1046+
}
1047+
10311048
// InviteUIDAttribute is the DSL attribute for invite UID in URL paths.
10321049
func InviteUIDAttribute() {
10331050
dsl.Attribute("invite_uid", dsl.String, "Committee invite UID", func() {

cmd/committee-api/service/committee_service_response.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ func (s *committeeServicesrvc) convertPayloadToBase(p *committeeservice.CreateCo
8787
func (s *committeeServicesrvc) convertPayloadToSettings(p *committeeservice.CreateCommitteePayload) *model.CommitteeSettings {
8888
settings := &model.CommitteeSettings{
8989
BusinessEmailRequired: p.BusinessEmailRequired,
90+
ChatWebhookURL: p.ChatWebhookURL,
9091
LastReviewedBy: p.LastReviewedBy,
9192
Writers: convertPayloadUsersToModel(p.Writers, nil),
9293
Auditors: convertPayloadUsersToModel(p.Auditors, nil),
@@ -295,6 +296,7 @@ func (s *committeeServicesrvc) convertPayloadToUpdateSettings(p *committeeservic
295296
settings := &model.CommitteeSettings{
296297
UID: *p.UID, // UID is required for updates
297298
BusinessEmailRequired: p.BusinessEmailRequired,
299+
ChatWebhookURL: p.ChatWebhookURL,
298300
LastReviewedAt: p.LastReviewedAt,
299301
LastReviewedBy: p.LastReviewedBy,
300302
Writers: convertPayloadUsersToModel(p.Writers, existingWriters),

gen/committee_service/service.go

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

gen/http/cli/committee/cli.go

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)