Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
4068129
feat: add private column to user_contact_methods table
mastercactapus May 14, 2025
cb3e091
feat: add private field to user_contact_methods and update related qu…
mastercactapus May 14, 2025
f86c083
feat: update contact method queries to support requester and owner pa…
mastercactapus May 14, 2025
3248f2d
feat: refactor contact methods queries to simplify parameters and inc…
mastercactapus May 14, 2025
8b5ced1
feat: add private field to contact methods and update related queries
mastercactapus May 14, 2025
3d74430
feat: enhance notification rule formatting to handle missing contact …
mastercactapus May 14, 2025
4a25157
feat: add private field to user contact methods and update related fo…
mastercactapus May 14, 2025
df42924
feat: update UserContactMethodForm to use 'private' field and simplif…
mastercactapus May 20, 2025
1c999cc
feat: update permission check in FindAll to use 'All' instead of spec…
mastercactapus May 22, 2025
fb5709a
feat: add tests for private contact methods visibility in GraphQL que…
mastercactapus May 22, 2025
d16bab6
feat: set 'private' field to false in user contact method stories
mastercactapus May 23, 2025
4509da8
Merge branch 'master' into private-cm
mastercactapus Jul 17, 2025
5ca2ff5
Merge branch 'master' into private-cm
mastercactapus Jul 30, 2025
59c9840
Merge branch 'master' into private-cm
mastercactapus Aug 1, 2025
07b906a
Merge remote-tracking branch 'origin/private-cm' into private-cm
mastercactapus Aug 1, 2025
ee0f9ba
Merge branch 'master' into private-cm
mastercactapus Sep 22, 2025
df5f54e
Merge branch 'master' into private-cm
mastercactapus Sep 29, 2025
49c5f13
update form test
mastercactapus Sep 29, 2025
aaa9b01
fix storybook ui
mastercactapus Sep 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ test-components: $(NODE_DEPS)
"$(WAITFOR) tcp://localhost:6008 && $(BIN_DIR)/tools/bun run test-storybook --ci --url http://127.0.0.1:6008 --maxWorkers 2"

storybook: $(NODE_DEPS) # Start the Storybook UI
$(BIN_DIR)/tools/bun run storybook
$(BIN_DIR)/tools/bun -b run storybook

playwright-run: $(NODE_DEPS) web/src/build/static/app.js bin/goalert.cover web/src/schema.d.ts $(BIN_DIR)/tools/prometheus $(BIN_DIR)/tools/mailpit reset-integration ## Start playwright tests in headless mode
rm -rf test/coverage/integration/playwright
Expand Down
3 changes: 3 additions & 0 deletions devtools/resetdb/datagen.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,9 @@ func (d *datagen) NewCM(userID string) {
if d.Bool() {
cm.Dest.Type = twilio.DestTypeTwilioVoice
}
if d.Intn(4) == 0 {
cm.Private = true
}

cm.Dest.SetArg(twilio.FieldPhoneNumber, d.ids.Gen(d.genPhone, cm.Dest.Type))
d.ContactMethods = append(d.ContactMethods, cm)
Expand Down
4 changes: 2 additions & 2 deletions devtools/resetdb/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,9 @@ func fillDB(ctx context.Context, dataCfg *datagenConfig, url string) error {
u := data.Users[n]
return []interface{}{asUUID(u.ID), u.Name, u.Role, u.Email}
})
copyFrom("user_contact_methods", []string{"id", "user_id", "name", "dest", "disabled", "pending"}, len(data.ContactMethods), func(n int) []interface{} {
copyFrom("user_contact_methods", []string{"id", "user_id", "name", "dest", "disabled", "pending", "private"}, len(data.ContactMethods), func(n int) []interface{} {
cm := data.ContactMethods[n]
return []interface{}{cm.ID, asUUID(cm.UserID), cm.Name, cm.Dest, cm.Disabled, cm.Pending}
return []interface{}{cm.ID, asUUID(cm.UserID), cm.Name, cm.Dest, cm.Disabled, cm.Pending, cm.Private}
}, "users")
copyFrom("user_notification_rules", []string{"id", "user_id", "contact_method_id", "delay_minutes"}, len(data.NotificationRules), func(n int) []interface{} {
nr := data.NotificationRules[n]
Expand Down
1 change: 1 addition & 0 deletions gadb/models.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 16 additions & 7 deletions gadb/queries.sql.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

67 changes: 65 additions & 2 deletions graphql2/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions graphql2/graphqlapp/contactmethod.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ func (m *Mutation) CreateUserContactMethod(ctx context.Context, input graphql2.C
UserID: input.UserID,
Disabled: true,
StatusUpdates: input.EnableStatusUpdates != nil && *input.EnableStatusUpdates,
Private: input.Private != nil && *input.Private,
}

if input.Dest != nil {
Expand Down Expand Up @@ -189,6 +190,9 @@ func (m *Mutation) UpdateUserContactMethod(ctx context.Context, input graphql2.U
}
cm.Name = *input.Name
}
if input.Private != nil {
cm.Private = *input.Private
}

if input.EnableStatusUpdates != nil {
cm.StatusUpdates = *input.EnableStatusUpdates
Expand Down
18 changes: 15 additions & 3 deletions graphql2/graphqlapp/dataloaders.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import (
"github.com/target/goalert/heartbeat"
"github.com/target/goalert/notification"
"github.com/target/goalert/notificationchannel"
"github.com/target/goalert/permission"
"github.com/target/goalert/schedule"
"github.com/target/goalert/schedule/rotation"
"github.com/target/goalert/service"
Expand Down Expand Up @@ -273,13 +274,24 @@ func (app *App) FindOneAlertMetric(ctx context.Context, id int) (*alertmetrics.M
}

// FindOneCM will return a single contact method for the given id, using the contexts dataloader if enabled.
func (app *App) FindOneCM(ctx context.Context, id uuid.UUID) (*contactmethod.ContactMethod, error) {
func (app *App) FindOneCM(ctx context.Context, id uuid.UUID) (cm *contactmethod.ContactMethod, err error) {
loader := loadersFrom(ctx).CM
if loader == nil {
return app.CMStore.FindOne(ctx, app.DB, id)
cm, err = app.CMStore.FindOne(ctx, app.DB, id)
} else {
cm, err = loader.FetchOne(ctx, id.String())
}
if err != nil {
return nil, err
}
if cm == nil {
return nil, nil
}
if cm.Private && cm.UserID != permission.UserID(ctx) {
return nil, nil
}

return loader.FetchOne(ctx, id.String())
return cm, nil
}

// FindOneNC will return a single notification channel for the given id, using the contexts dataloader if enabled.
Expand Down
3 changes: 2 additions & 1 deletion graphql2/graphqlapp/user.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,8 @@ func (a *User) Role(ctx context.Context, usr *user.User) (graphql2.UserRole, err
}

func (a *User) ContactMethods(ctx context.Context, obj *user.User) ([]contactmethod.ContactMethod, error) {
return a.CMStore.FindAll(ctx, a.DB, obj.ID)
cm, _, err := a.CMStore.FindAll(ctx, a.DB, obj.ID)
return cm, err
}

func (a *User) NotificationRules(ctx context.Context, obj *user.User) ([]notificationrule.NotificationRule, error) {
Expand Down
4 changes: 4 additions & 0 deletions graphql2/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading