Loading server/api_user.go +5 −15 Original line number Diff line number Diff line Loading @@ -47,15 +47,13 @@ func (s *ApiServer) GetUsers(ctx context.Context, in *api.GetUsersRequest) (*api } } if in.GetIds() == nil && in.GetUsernames() == nil && in.GetFacebookIds() == nil { if len(in.GetIds()) == 0 && len(in.GetUsernames()) == 0 && len(in.GetFacebookIds()) == 0 { return &api.Users{}, nil } ids := make([]string, 0) usernames := make([]string, 0) facebookIDs := make([]string, 0) if in.GetIds() != nil { var ids []string if len(in.GetIds()) != 0 { ids = make([]string, 0, len(in.GetIds())) for _, id := range in.GetIds() { if _, uuidErr := uuid.FromString(id); uuidErr != nil { return nil, status.Error(codes.InvalidArgument, "ID '"+id+"' is not a valid system ID.") Loading @@ -65,15 +63,7 @@ func (s *ApiServer) GetUsers(ctx context.Context, in *api.GetUsersRequest) (*api } } if in.GetUsernames() != nil { usernames = in.GetUsernames() } if in.GetFacebookIds() != nil { facebookIDs = in.GetFacebookIds() } users, err := GetUsers(ctx, s.logger, s.db, s.tracker, ids, usernames, facebookIDs) users, err := GetUsers(ctx, s.logger, s.db, s.tracker, ids, in.GetUsernames(), in.GetFacebookIds()) if err != nil { return nil, status.Error(codes.Internal, "Error retrieving user accounts.") } Loading server/console_api_explorer.go +4 −5 Original line number Diff line number Diff line Loading @@ -145,13 +145,12 @@ func (s *ConsoleServer) extractApiCallContext(ctx context.Context, in *console.C } func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (*console.ApiEndpointList, error) { endpointNames := make([]string, 0) endpointNames := make([]string, 0, len(s.rpcMethodCache.endpoints)) for name := range s.rpcMethodCache.endpoints { endpointNames = append(endpointNames, string(name)) } sort.Strings(endpointNames) var endpoints []*console.ApiEndpointDescriptor endpoints := make([]*console.ApiEndpointDescriptor, 0, len(endpointNames)) for _, name := range endpointNames { endpoint := s.rpcMethodCache.endpoints[MethodName(name)] endpoints = append(endpoints, &console.ApiEndpointDescriptor{ Loading @@ -160,12 +159,12 @@ func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (* }) } rpcs := make([]string, 0) rpcs := make([]string, 0, len(s.rpcMethodCache.rpcs)) for name := range s.rpcMethodCache.rpcs { rpcs = append(rpcs, string(name)) } sort.Strings(rpcs) var rpcEndpoints []*console.ApiEndpointDescriptor rpcEndpoints := make([]*console.ApiEndpointDescriptor, 0, len(rpcs)) for _, name := range rpcs { endpoint := s.rpcMethodCache.rpcs[MethodName(name)] rpcEndpoints = append(rpcEndpoints, &console.ApiEndpointDescriptor{ Loading server/console_user.go +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ func (s *ConsoleServer) ListUsers(ctx context.Context, in *empty.Empty) (*consol } func (s *ConsoleServer) dbListConsoleUsers(ctx context.Context) ([]*console.UserList_User, error) { result := make([]*console.UserList_User, 0) result := make([]*console.UserList_User, 0, 10) rows, err := s.db.QueryContext(ctx, "SELECT username, email, role FROM console_user") if err != nil { return nil, err Loading server/core_account.go +1 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,7 @@ func ExportAccount(ctx context.Context, logger *zap.Logger, db *sql.DB, userID u return nil, status.Error(codes.Internal, "An error occurred while trying to export user data.") } groups := make([]*api.Group, 0) groups := make([]*api.Group, 0, 1) groupUsers, err := ListUserGroups(ctx, logger, db, userID, 0, nil, "") if err != nil { logger.Error("Could not fetch groups that belong to the user", zap.Error(err), zap.String("user_id", userID.String())) Loading server/core_authenticate.go +4 −4 Original line number Diff line number Diff line Loading @@ -800,8 +800,8 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, if err != nil { return err } statements := make([]string, 0) params := make([]interface{}, 0) statements := make([]string, 0, 10) params := make([]interface{}, 0, 10) for rows.Next() { var id string err = rows.Scan(&id) Loading Loading @@ -852,7 +852,7 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, } var id string possibleFriendIDs := make([]uuid.UUID, 0) possibleFriendIDs := make([]uuid.UUID, 0, len(statements)) for rows.Next() { err = rows.Scan(&id) if err != nil { Loading @@ -868,7 +868,7 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, _ = rows.Close() // If the transaction is retried ensure we wipe any friend user IDs that may have been recorded by previous attempts. friendUserIDs = make([]uuid.UUID, 0) friendUserIDs = make([]uuid.UUID, 0, len(possibleFriendIDs)) for _, friendID := range possibleFriendIDs { position := fmt.Sprintf("%v", time.Now().UTC().UnixNano()) Loading Loading
server/api_user.go +5 −15 Original line number Diff line number Diff line Loading @@ -47,15 +47,13 @@ func (s *ApiServer) GetUsers(ctx context.Context, in *api.GetUsersRequest) (*api } } if in.GetIds() == nil && in.GetUsernames() == nil && in.GetFacebookIds() == nil { if len(in.GetIds()) == 0 && len(in.GetUsernames()) == 0 && len(in.GetFacebookIds()) == 0 { return &api.Users{}, nil } ids := make([]string, 0) usernames := make([]string, 0) facebookIDs := make([]string, 0) if in.GetIds() != nil { var ids []string if len(in.GetIds()) != 0 { ids = make([]string, 0, len(in.GetIds())) for _, id := range in.GetIds() { if _, uuidErr := uuid.FromString(id); uuidErr != nil { return nil, status.Error(codes.InvalidArgument, "ID '"+id+"' is not a valid system ID.") Loading @@ -65,15 +63,7 @@ func (s *ApiServer) GetUsers(ctx context.Context, in *api.GetUsersRequest) (*api } } if in.GetUsernames() != nil { usernames = in.GetUsernames() } if in.GetFacebookIds() != nil { facebookIDs = in.GetFacebookIds() } users, err := GetUsers(ctx, s.logger, s.db, s.tracker, ids, usernames, facebookIDs) users, err := GetUsers(ctx, s.logger, s.db, s.tracker, ids, in.GetUsernames(), in.GetFacebookIds()) if err != nil { return nil, status.Error(codes.Internal, "Error retrieving user accounts.") } Loading
server/console_api_explorer.go +4 −5 Original line number Diff line number Diff line Loading @@ -145,13 +145,12 @@ func (s *ConsoleServer) extractApiCallContext(ctx context.Context, in *console.C } func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (*console.ApiEndpointList, error) { endpointNames := make([]string, 0) endpointNames := make([]string, 0, len(s.rpcMethodCache.endpoints)) for name := range s.rpcMethodCache.endpoints { endpointNames = append(endpointNames, string(name)) } sort.Strings(endpointNames) var endpoints []*console.ApiEndpointDescriptor endpoints := make([]*console.ApiEndpointDescriptor, 0, len(endpointNames)) for _, name := range endpointNames { endpoint := s.rpcMethodCache.endpoints[MethodName(name)] endpoints = append(endpoints, &console.ApiEndpointDescriptor{ Loading @@ -160,12 +159,12 @@ func (s *ConsoleServer) ListApiEndpoints(ctx context.Context, _ *empty.Empty) (* }) } rpcs := make([]string, 0) rpcs := make([]string, 0, len(s.rpcMethodCache.rpcs)) for name := range s.rpcMethodCache.rpcs { rpcs = append(rpcs, string(name)) } sort.Strings(rpcs) var rpcEndpoints []*console.ApiEndpointDescriptor rpcEndpoints := make([]*console.ApiEndpointDescriptor, 0, len(rpcs)) for _, name := range rpcs { endpoint := s.rpcMethodCache.rpcs[MethodName(name)] rpcEndpoints = append(rpcEndpoints, &console.ApiEndpointDescriptor{ Loading
server/console_user.go +1 −1 Original line number Diff line number Diff line Loading @@ -104,7 +104,7 @@ func (s *ConsoleServer) ListUsers(ctx context.Context, in *empty.Empty) (*consol } func (s *ConsoleServer) dbListConsoleUsers(ctx context.Context) ([]*console.UserList_User, error) { result := make([]*console.UserList_User, 0) result := make([]*console.UserList_User, 0, 10) rows, err := s.db.QueryContext(ctx, "SELECT username, email, role FROM console_user") if err != nil { return nil, err Loading
server/core_account.go +1 −1 Original line number Diff line number Diff line Loading @@ -401,7 +401,7 @@ func ExportAccount(ctx context.Context, logger *zap.Logger, db *sql.DB, userID u return nil, status.Error(codes.Internal, "An error occurred while trying to export user data.") } groups := make([]*api.Group, 0) groups := make([]*api.Group, 0, 1) groupUsers, err := ListUserGroups(ctx, logger, db, userID, 0, nil, "") if err != nil { logger.Error("Could not fetch groups that belong to the user", zap.Error(err), zap.String("user_id", userID.String())) Loading
server/core_authenticate.go +4 −4 Original line number Diff line number Diff line Loading @@ -800,8 +800,8 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, if err != nil { return err } statements := make([]string, 0) params := make([]interface{}, 0) statements := make([]string, 0, 10) params := make([]interface{}, 0, 10) for rows.Next() { var id string err = rows.Scan(&id) Loading Loading @@ -852,7 +852,7 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, } var id string possibleFriendIDs := make([]uuid.UUID, 0) possibleFriendIDs := make([]uuid.UUID, 0, len(statements)) for rows.Next() { err = rows.Scan(&id) if err != nil { Loading @@ -868,7 +868,7 @@ func importFacebookFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, _ = rows.Close() // If the transaction is retried ensure we wipe any friend user IDs that may have been recorded by previous attempts. friendUserIDs = make([]uuid.UUID, 0) friendUserIDs = make([]uuid.UUID, 0, len(possibleFriendIDs)) for _, friendID := range possibleFriendIDs { position := fmt.Sprintf("%v", time.Now().UTC().UnixNano()) Loading