MCPcopy Index your code
hub / github.com/coder/coder / parseUser

Function parseUser

coderd/searchquery/search.go:723–743  ·  view source on GitHub ↗
(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string, actorID uuid.UUID)

Source from the content-addressed store, hash-verified

721}
722
723func parseUser(ctx context.Context, db database.Store, parser *httpapi.QueryParamParser, vals url.Values, queryParam string, actorID uuid.UUID) uuid.UUID {
724 return httpapi.ParseCustom(parser, vals, uuid.Nil, queryParam, func(v string) (uuid.UUID, error) {
725 if v == "" {
726 return uuid.Nil, nil
727 }
728 if v == codersdk.Me && actorID != uuid.Nil {
729 return actorID, nil
730 }
731 userID, err := uuid.Parse(v)
732 if err == nil {
733 return userID, nil
734 }
735 user, err := db.GetUserByEmailOrUsername(ctx, database.GetUserByEmailOrUsernameParams{
736 Username: v,
737 })
738 if err != nil {
739 return uuid.Nil, xerrors.Errorf("user %q either does not exist, or you are unauthorized to view them", v)
740 }
741 return user.ID, nil
742 })
743}
744
745// Parse a group filter value into a group UUID.
746// Supported formats:

Callers 4

WorkspacesFunction · 0.85
AIBridgeInterceptionsFunction · 0.85
AIBridgeSessionsFunction · 0.85
TasksFunction · 0.85

Calls 4

ParseCustomFunction · 0.92
ParseMethod · 0.65
ErrorfMethod · 0.45

Tested by

no test coverage detected