mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: enable coder inbox by default (#17077)
Add a flag to enable Coder Inbox by default, as well as supporting disabling the feature.
This commit is contained in:
+22
-26
@@ -920,34 +920,30 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd.
|
||||
notificationsManager *notifications.Manager
|
||||
)
|
||||
|
||||
if notificationsCfg.Enabled() {
|
||||
metrics := notifications.NewMetrics(options.PrometheusRegistry)
|
||||
helpers := templateHelpers(options)
|
||||
metrics := notifications.NewMetrics(options.PrometheusRegistry)
|
||||
helpers := templateHelpers(options)
|
||||
|
||||
// The enqueuer is responsible for enqueueing notifications to the given store.
|
||||
enqueuer, err := notifications.NewStoreEnqueuer(notificationsCfg, options.Database, helpers, logger.Named("notifications.enqueuer"), quartz.NewReal())
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to instantiate notification store enqueuer: %w", err)
|
||||
}
|
||||
options.NotificationsEnqueuer = enqueuer
|
||||
|
||||
// The notification manager is responsible for:
|
||||
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
|
||||
// - keeping the store updated with status updates
|
||||
notificationsManager, err = notifications.NewManager(notificationsCfg, options.Database, options.Pubsub, helpers, metrics, logger.Named("notifications.manager"))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to instantiate notification manager: %w", err)
|
||||
}
|
||||
|
||||
// nolint:gocritic // We need to run the manager in a notifier context.
|
||||
notificationsManager.Run(dbauthz.AsNotifier(ctx))
|
||||
|
||||
// Run report generator to distribute periodic reports.
|
||||
notificationReportGenerator := reports.NewReportGenerator(ctx, logger.Named("notifications.report_generator"), options.Database, options.NotificationsEnqueuer, quartz.NewReal())
|
||||
defer notificationReportGenerator.Close()
|
||||
} else {
|
||||
logger.Debug(ctx, "notifications are currently disabled as there are no configured delivery methods. See https://coder.com/docs/admin/monitoring/notifications#delivery-methods for more details")
|
||||
// The enqueuer is responsible for enqueueing notifications to the given store.
|
||||
enqueuer, err := notifications.NewStoreEnqueuer(notificationsCfg, options.Database, helpers, logger.Named("notifications.enqueuer"), quartz.NewReal())
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to instantiate notification store enqueuer: %w", err)
|
||||
}
|
||||
options.NotificationsEnqueuer = enqueuer
|
||||
|
||||
// The notification manager is responsible for:
|
||||
// - creating notifiers and managing their lifecycles (notifiers are responsible for dequeueing/sending notifications)
|
||||
// - keeping the store updated with status updates
|
||||
notificationsManager, err = notifications.NewManager(notificationsCfg, options.Database, options.Pubsub, helpers, metrics, logger.Named("notifications.manager"))
|
||||
if err != nil {
|
||||
return xerrors.Errorf("failed to instantiate notification manager: %w", err)
|
||||
}
|
||||
|
||||
// nolint:gocritic // We need to run the manager in a notifier context.
|
||||
notificationsManager.Run(dbauthz.AsNotifier(ctx))
|
||||
|
||||
// Run report generator to distribute periodic reports.
|
||||
notificationReportGenerator := reports.NewReportGenerator(ctx, logger.Named("notifications.report_generator"), options.Database, options.NotificationsEnqueuer, quartz.NewReal())
|
||||
defer notificationReportGenerator.Close()
|
||||
|
||||
// Since errCh only has one buffered slot, all routines
|
||||
// sending on it must be wrapped in a select/default to
|
||||
|
||||
+1
-1
@@ -298,7 +298,7 @@ func TestServer(t *testing.T) {
|
||||
out := pty.ReadAll()
|
||||
numLines := countLines(string(out))
|
||||
t.Logf("numLines: %d", numLines)
|
||||
require.Less(t, numLines, 12, "expected less than 12 lines of output (terminal width 80), got %d", numLines)
|
||||
require.Less(t, numLines, 20, "expected less than 20 lines of output (terminal width 80), got %d", numLines)
|
||||
})
|
||||
|
||||
t.Run("OAuth2GitHubDefaultProvider", func(t *testing.T) {
|
||||
|
||||
+4
@@ -473,6 +473,10 @@ Configure TLS for your SMTP server target.
|
||||
Enable STARTTLS to upgrade insecure SMTP connections using TLS.
|
||||
DEPRECATED: Use --email-tls-starttls instead.
|
||||
|
||||
NOTIFICATIONS / INBOX OPTIONS:
|
||||
--notifications-inbox-enabled bool, $CODER_NOTIFICATIONS_INBOX_ENABLED (default: true)
|
||||
Enable Coder Inbox.
|
||||
|
||||
NOTIFICATIONS / WEBHOOK OPTIONS:
|
||||
--notifications-webhook-endpoint url, $CODER_NOTIFICATIONS_WEBHOOK_ENDPOINT
|
||||
The endpoint to which to send webhooks.
|
||||
|
||||
+4
@@ -643,6 +643,10 @@ notifications:
|
||||
# The endpoint to which to send webhooks.
|
||||
# (default: <unset>, type: url)
|
||||
endpoint:
|
||||
inbox:
|
||||
# Enable Coder Inbox.
|
||||
# (default: true, type: bool)
|
||||
enabled: true
|
||||
# The upper limit of attempts to send a notification.
|
||||
# (default: 5, type: int)
|
||||
maxSendAttempts: 5
|
||||
|
||||
Reference in New Issue
Block a user