- Notifications
You must be signed in to change notification settings - Fork1k
feat!: allow disabling notifications#15509
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes fromall commits
5c36c93
196f538
b670009
19398cc
4175bc8
66d1a69
4689e5b
01d4957
27fa5bf
6ca7844
fb54e45
d5aff28
01cb999
c513113
a8b5a61
1711e68
2e03ed1
28ec1b7
7ba3a6c
4a72e4f
9c02842
dd527f9
77d1803
5fd03b3
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -686,11 +686,15 @@ type NotificationsConfig struct { | ||
Webhook NotificationsWebhookConfig `json:"webhook" typescript:",notnull"` | ||
} | ||
func (n *NotificationsConfig) Enabled() bool { | ||
DanielleMaywood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
return n.SMTP.Smarthost != "" || n.Webhook.Endpoint != serpent.URL{} | ||
DanielleMaywood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
} | ||
type NotificationsEmailConfig struct { | ||
// The sender's address. | ||
From serpent.String `json:"from" typescript:",notnull"` | ||
// The intermediary SMTP host through which emails are sent (host:port). | ||
Smarthost serpent.String `json:"smarthost" typescript:",notnull"` | ||
// The hostname identifying the SMTP server. | ||
Hello serpent.String `json:"hello" typescript:",notnull"` | ||
@@ -1028,7 +1032,6 @@ when required by your organization's security policy.`, | ||
Description: "The intermediary SMTP host through which emails are sent.", | ||
Flag: "email-smarthost", | ||
Env: "CODER_EMAIL_SMARTHOST", | ||
Value: &c.Notifications.SMTP.Smarthost, | ||
Group: &deploymentGroupEmail, | ||
YAML: "smarthost", | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -568,3 +568,69 @@ func TestPremiumSuperSet(t *testing.T) { | ||
require.NotContains(t, enterprise.Features(), "", "enterprise should not contain empty string") | ||
require.NotContains(t, premium.Features(), "", "premium should not contain empty string") | ||
} | ||
func TestNotificationsCanBeDisabled(t *testing.T) { | ||
t.Parallel() | ||
tests := []struct { | ||
name string | ||
expectNotificationsEnabled bool | ||
environment []serpent.EnvVar | ||
}{ | ||
{ | ||
name: "NoDeliveryMethodSet", | ||
environment: []serpent.EnvVar{}, | ||
expectNotificationsEnabled: false, | ||
}, | ||
{ | ||
name: "SMTP_DeliveryMethodSet", | ||
environment: []serpent.EnvVar{ | ||
{ | ||
Name: "CODER_EMAIL_SMARTHOST", | ||
Value: "localhost:587", | ||
}, | ||
}, | ||
expectNotificationsEnabled: true, | ||
}, | ||
{ | ||
name: "Webhook_DeliveryMethodSet", | ||
environment: []serpent.EnvVar{ | ||
{ | ||
Name: "CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT", | ||
Value: "https://example.com/webhook", | ||
}, | ||
}, | ||
expectNotificationsEnabled: true, | ||
}, | ||
{ | ||
name: "WebhookAndSMTP_DeliveryMethodSet", | ||
environment: []serpent.EnvVar{ | ||
{ | ||
Name: "CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT", | ||
Value: "https://example.com/webhook", | ||
}, | ||
{ | ||
Name: "CODER_EMAIL_SMARTHOST", | ||
Value: "localhost:587", | ||
}, | ||
}, | ||
expectNotificationsEnabled: true, | ||
}, | ||
} | ||
for _, tt := range tests { | ||
tt := tt | ||
DanielleMaywood marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
t.Run(tt.name, func(t *testing.T) { | ||
t.Parallel() | ||
dv := codersdk.DeploymentValues{} | ||
opts := dv.Options() | ||
err := opts.ParseEnv(tt.environment) | ||
require.NoError(t, err) | ||
require.Equal(t, tt.expectNotificationsEnabled, dv.Notifications.Enabled()) | ||
}) | ||
} | ||
} |
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.