@@ -3,6 +3,7 @@ package notifications
3
3
import (
4
4
"context"
5
5
"encoding/json"
6
+ "fmt"
6
7
"slices"
7
8
"strings"
8
9
"text/template"
25
26
ErrDuplicate = xerrors .New ("duplicate notification" )
26
27
)
27
28
29
+ type InvalidDefaultNotificationMethodError struct {
30
+ Method string
31
+ }
32
+
33
+ func (e InvalidDefaultNotificationMethodError )Error ()string {
34
+ return fmt .Sprintf ("given default notification method %q is invalid" ,e .Method )
35
+ }
36
+
28
37
type StoreEnqueuer struct {
29
38
store Store
30
39
log slog.Logger
@@ -43,8 +52,13 @@ type StoreEnqueuer struct {
43
52
// NewStoreEnqueuer creates an Enqueuer implementation which can persist notification messages in the store.
44
53
func NewStoreEnqueuer (cfg codersdk.NotificationsConfig ,store Store ,helpers template.FuncMap ,log slog.Logger ,clock quartz.Clock ) (* StoreEnqueuer ,error ) {
45
54
var method database.NotificationMethod
46
- if err := method .Scan (cfg .Method .String ());err != nil {
47
- return nil ,xerrors .Errorf ("given notification method %q is invalid" ,cfg .Method )
55
+ // TODO(DanielleMaywood):
56
+ // Currently we do not want to allow setting `inbox` as the default notification method.
57
+ // As of 2025-03-25, setting this to `inbox` would cause a crash on the deployment
58
+ // notification settings page. Until we make a future decision on this we want to disallow
59
+ // setting it.
60
+ if err := method .Scan (cfg .Method .String ());err != nil || method == database .NotificationMethodInbox {
61
+ return nil ,InvalidDefaultNotificationMethodError {Method :cfg .Method .String ()}
48
62
}
49
63
50
64
return & StoreEnqueuer {