Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

chore: simplify system bot code (#16022)

Danny Xu6283737491d0
diff --git a/backend/api/v1/user_service.go b/backend/api/v1/user_service.go
index 6a429a23e7..3638c853b1 100644
--- a/backend/api/v1/user_service.go
+++ b/backend/api/v1/user_service.go
@@ -690,14 +690,13 @@ func (s *UserService) getActiveUserCount(ctx context.Context) (int, error) {
func (s *UserService) hasExtraWorkspaceAdmin(ctx context.Context, policy *storepb.IamPolicy, userID int) (bool, error) {
workspaceAdminRole := common.FormatRole(base.WorkspaceAdmin.String())
userMember := common.FormatUserUID(userID)
- systemBotMember := common.FormatUserUID(base.SystemBotID)
for _, binding := range policy.GetBindings() {
if binding.GetRole() != workspaceAdminRole {
continue
}
for _, member := range binding.GetMembers() {
- if member == userMember || member == systemBotMember {
+ if member == userMember {
continue
}
if member == base.AllUsers {
diff --git a/backend/base/principal.go b/backend/base/principal.go
index 62f9f15420..037cf79b22 100644
--- a/backend/base/principal.go
+++ b/backend/base/principal.go
@@ -3,9 +3,6 @@ package base
// SystemBotID is the ID of the system robot.
const SystemBotID = 1
-// SystemBotEmail is the email of the system robot.
-const SystemBotEmail = "[email protected]"
-
// AllUsers is the email of the pseudo allUsers account.
const AllUsers = "allUsers"
diff --git a/backend/server/init.go b/backend/server/init.go
index 5b401a1914..94f4982802 100644
--- a/backend/server/init.go
+++ b/backend/server/init.go
@@ -178,16 +178,6 @@ func (s *Server) initializeSetting(ctx context.Context) error {
return err
}
- // Init workspace IAM policy
- // Ensure the admin role for system bot.
- if _, err := s.store.PatchWorkspaceIamPolicy(ctx, &store.PatchIamPolicyMessage{
- Member: common.FormatUserUID(base.SystemBotID),
- Roles: []string{
- common.FormatRole(base.WorkspaceAdmin.String()),
- },
- }); err != nil {
- return err
- }
if firstTimeOnboarding {
// Only grant workspace member role to allUsers at the first time.
if _, err := s.store.PatchWorkspaceIamPolicy(ctx, &store.PatchIamPolicyMessage{
diff --git a/backend/store/principal.go b/backend/store/principal.go
index 433f6117b6..b593a3d47a 100644
--- a/backend/store/principal.go
+++ b/backend/store/principal.go
@@ -21,7 +21,7 @@ import (
var systemBotUser = &UserMessage{
ID: base.SystemBotID,
Name: "Bytebase",
- Email: base.SystemBotEmail,
+ Email: "[email protected]",
Type: base.SystemBot,
}