Skip to content
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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DDO-3863] Fix notification context for suspending users #652

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func suspendRoleAssignments(ctx context.Context, db *gorm.DB) error {
// Assume super-user privileges for this operation (required to edit RoleAssignments)
superUserDB := models.SetCurrentUserForDB(db, models.SelfUser)
// Squelch notifications where possible because we notify at the end
superUserDB = superUserDB.WithContext(slack.SetContextToSquelchPermissionChangeNotifications(ctx))
superUserDB = superUserDB.WithContext(slack.SetContextToSquelchPermissionChangeNotifications(superUserDB.Statement.Context))

roleIDsRequiringPropagation := make(map[uint]struct{})
var summaries []string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ func (s *suspendRoleAssignmentsSuite) Test_suspendRoleAssignments() {
s.NoError(s.DB.Create(&assignment4).Error)
s.NoError(s.DB.Create(&assignment5).Error)

s.SetSuitableTestUserForDB() // Check that it elevates its own permissions properly

slack.UseMockedClient(s.T(), func(c *slack_mocks.MockMockableClient) {
c.EXPECT().SendMessageContext(mock.Anything, "#notification-channel", mock.Anything).Return("", "", "", nil).Once()
c.EXPECT().SendMessageContext(mock.Anything, "#permission-change-channel", mock.Anything).Return("", "", "", nil).Once()
Expand Down
Loading